Deleting Cookies


document.cookie="myLanguage=JavaScript; expires=Thu, 25-Dec-1980 12:34:56 GMT" 

Setting a cookie value to an empty string effectively destroys the cookie data, but does not eliminate the cookie itself. To get rid of a cookie, the expiration date must be set to some point in the past. Since the UNIX time measuring starts on January 1, 1970, a date somewhere close to this point is recommended. The preceding code (see deletecookie.html) uses Christmas 1980 as the cookie expiration date. The web browser sees that this date lies in the past (unless the user changed the local time settings) and deletes the cookie. Once again, it is important that the same cookie features are used as when the cookie was set.




JavaScript Phrasebook(c) Essential Code and Commands
JavaScript Phrasebook
ISBN: 0672328801
EAN: 2147483647
Year: 2006
Pages: 178

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net