How to Delete a Cookie?
Mike Driscoll
kyosohma at gmail.com
Thu Jan 8 12:11:44 EST 2009
On Jan 8, 9:16 am, tryg.ol... at gmail.com wrote:
> Hello -
>
> I managed to get a cookie set. Now I want to delete it but it is not
> working.
>
> Do I need to do another 'set-cookie' in the HTTP header? I tried
> (code below setting expires to 0) and it didn't work.
> c = Cookie.SimpleCookie(os.environ["HTTP_COOKIE"])
> c["mycook"]["expires"] = 0
> print c
>
> In case its useful, here is how I set my cookie:
> c = Cookie.SimpleCookie()
> c["mycook"] = "Tryg"
> c["mycook"]["expires"] = 60*60*24
> c["mycook"]["comment"] = ""
> c["mycook"]["path"] = "/"
> c["mycook"]["domain"] = ""
> c["mycook"]["secure"] = ""
> print c
>
> Thanks
> Tryg
Well, if you know where the cookie file is stored, you should be able
to do this:
os.remove(path)
Mike
More information about the Python-list
mailing list