cookie setting

Dave Harrison dave at nullcube.com
Sun May 11 07:57:37 EDT 2003


I've been working on implementing cookies,

and I've pretty much got it sorted, but I have two questions :

(1) How to I get rid of a users cookie ? Best I can think of at the moment is setting the expire time to the current time and having it expire that way.

(2) Why when I use the following code am I getting an output tuple of ('123', '123') ?

httpstring = os.environ['HTTP_COOKIE']
COOKIE = Cookie.SimpleCookie()
COOKIE.load(httpstring)

print COOKIE['3802Cookie'].value


cheers
Dave

P.S Here is my cookie setting code as well :

c = Cookie.SimpleCookie()
c['3802Cookie'] = c.value_encode('123')
c['3802Cookie']['max-age'] = '3600'

print 'Content-Type: text/html'
print c
print
print
print '<html><body>'
print '<center>'
print '<p>Cookie Testing</p>'
print '</body></html>'





More information about the Python-list mailing list