[thelist] deleting a JS cookie

Keith cache at dowebscentral.com
Fri Dec 20 17:27:01 CST 2002


At 07:21 AM Thursday 12/19/2002, you wrote:
>I am setting this cookie:
>
>document.cookie = "groom=<?=$groom?>; expires=Wdy, 01-Mon-2010
>12:12:12 GMT; path=/";
>
>Then, to delete it I am trying:
>
>document.cookie = "groom=nothing; path=/; expires=Thu, 01-Jan-70
>12:00:01 GMT";
>
>This doesn't work, it sets it to 'nothing' even with the date at
>1970. Is there a better way, what mistake am I making?

To reliably delete a cookie w/javascript you have to give it a real date in
the past. With IE6 the cookie will not actually disappear until the browser
is closed.

<snippet>
when=new Date()
when.setMonth(when.getMonth()-12)
expiry=when.toGMTString()
document.cookie="groom=nuthin;path=/;expires="+expiry
</snippet>


Keith
====================
cache at dowebscentral.com




More information about the thelist mailing list