web blazonry web development scripts and tutorials
 
Web blazonry.com
   Home       PHP       Name Generators       Perl       CSS       Javascript       Java       devTips       Resources   

Javascript Home


image scripts
  Image Load Order
  Mouse Overs
  SlideShow

JavaScript Resources
  Free JavaScript Books(new)
  Recommended Sites
  Bestselling Books





JavaScript: How to Work With Cookies (Part 4)

Deleting a Cookie

To remove or delete a cookie, you can set its expiration date to now, or, set it to 0. You can also use a function to delete the cookie.

<script language="JavaScript"><!--
// This function deletes a cookie
function delCookie(name) {
document.cookie = name + "=; expires=Thu, 01-Jan-70 00:00:01 GMT" + "; path=/";
}
//-->
</script>

Then, when you want to delete the cookie, use:
delCookie("myCookie");

Let’s make sure our cookie is there (if not, go back and set it):

Now, let’s delete that cookie with a button.

Now try the “get cookie value” button again and see if our cookie is there:

The form field should be blank if you are using Firefox (it cannot find the cookie it is looking for) or say “null” (MS Internet Explorer). You can also use your browser to look at all your cookies to see if our cookie is there (instructions are in the Overview of Cookies).


Next >> Cookies: Putting It All Together & Summary

 

Related Links:

    Cookie Central -- a site devoted completely to information about cookies.

 

Newest Pages
Test Google Ads Part 2
Free Linux Admin Books
Free Linux Books for Programmers
Free Books for Linux on the Desktop
Free PHP Books
Free JavaScript Books
Free Java Books - Advanced
Free Java Books - Basic
Free Perl Books
Free Python Books
Quote of the Day (PHP)
Debugging Part 2
How to Test Google Ads
Most Popular Pages
U.S. Name Generator
Baby Name Generator
Wu Name Generator
Popup Windows (JavaScript)
Intro to Web Databases (PHP, MySQL)
Upload and Resize an Image (PHP)
How To Install Apache + PHP + MySQL

Least Popular Pages
iNews Aplet (Java)
Java Resources)
Site Monitor (Perl)
Load Order of Images(Javascript)
 
 

  © 1997-2008. astonishinc.com   All Rights Reserved.