HTTP_COOKIE variable not set
Bevan Koopman
bevank at dstc.edu.au
Mon Feb 25 00:26:15 EST 2002
Hi there,
When I run the script below the 'HTTP_COOKIE' environment variable is
not set, i.e. "HTTP_COOKIE" does not appear in the scripts output:
#####################
import cgi
import os
import Cookie
print "Content-Type:text/html\n\n"
cookie = Cookie.SimpleCookie()
cookie["user"] = the_user
print os.environ
#####################
Hence when I run the following script the key is not found
#####################
import cgi
import os
import Cookie
c = Cookie.SimpleCookie()
if(os.environ.has_key('HTTP_COOKIE')):
c.load(os.environ['HTTP_COOKIE'])
print c["user"].value
else:
print "no user"
#####################
How do I correctly create the cookie so I can retrieve in the second
script.
Thanks,
--
| _ _
|\|_\ //_\|\ | bevan koopman
|/|_ \/ | || \| bevan at dstc.edu.au
Distributed Systems Technology Centre
http://www.dstc.edu.au
More information about the Python-list
mailing list