1/27/2007

Cookie doesn't work

When I used Python to creat cookies, it didn't work and I tried hard to figure it out. Finally I found that the cookie must be printed out so that it can be sent in the header. For example:
c = Cookie.SimpleCookie()
c["user"]="python"
print c.output()
print "Content-Type: text/html\n"

The following one won't work:
c = Cookie.SimpleCookie()
c["user"]="python"
print "Content-Type: text/html\n"
print c.output()
This is because the c is printed out as html content instead of header.

No comments: