web blazonry web development scripts and tutorials Get best price on Unlocked Moto G Stylus
   PHP       Name Generators       Perl       CSS       Javascript       Java       MySql       How Tos       Resources   

Javascript Home


image scripts
  Image Load Order
  Mouse Overs
  SlideShow

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

Bookmark and Share




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 Ver. 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
Baby Name Generator
U.S. Name Generator
Wu Name Generator
Popup Windows (JavaScript)
Upload and Resize an Image (PHP)
How To Install Apache + PHP + MySQL
Intro to Web Databases (PHP, MySQL)

Least Popular Pages
iNews Applet (Java)
Java Resources
Site Monitor (Perl)
PHP Resources
 
 

  privacy policy     ||     © 1997-2016. astonishinc.com   All Rights Reserved.