How to Delete a Cookie?

tryg.olson at tryg.olson at
Thu Jan 8 16:16:42 CET 2009

Hello -

I managed to get a cookie set.  Now I want to delete it but it is not

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


More information about the Python-list mailing list