Deleting Cookies
At some point, you’re going to want to delete a cookie or many cookies in a cookie record. It’s fairly easy to do; one technique that works well is to simply set the cookie’s expiration date to a date in the past, which causes the browser to delete it automatically. Script 10.7 shows how to force your cookies to become stale.
To delete cookies:
1. | var cookieCt = 0; |
2. | if (document.cookie != "" && confirm ("Do you want to delete the cookies?")) { |
Get JavaScript and Ajax for the Web: Visual QuickStart Guide, Seventh Edition now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.