How to Delete a Cookie?

tryg.olson at gmail.com tryg.olson at gmail.com
Thu Jan 8 10:16:42 EST 2009


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



More information about the Python-list mailing list