Get best price on Unlocked Moto G Stylus | ||||||||||||
|
||||||||||||
|
JavaScript: How to Work With Cookies (Part 4)Deleting a CookieTo 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");
Lets make sure our cookie is there (if not, go back and set it): Now, lets 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.
|
privacy policy || © 1997-2016. astonishinc.com All Rights Reserved. |