Problem dealing with cookies
Fazer
faizan at jaredweb.com
Sun Aug 3 00:35:46 EDT 2003
Hello,
I have the following code:
#!/usr/local/bin/python
import cgi
import Cookie
C = Cookie.SimpleCookie()
C["moo"] = "f"
C["moo"]["path"] = "/"
C["moo"]["expires"] = 60*60*60*60
#Print the headers
print C
print "Content-Type: text/html\n"
#Print starting html
print "<html><head><title>Cookie</title></head><body>"
form = cgi.FieldStorage()
if C['moo'].value != "f":
print "I remember you %s" % (C["moo"].value)
elif form.has_key("name") and C["moo"].value == "f":
print "Thank you %s!" % (form["name"].value)
C["moo"] = form['name'].value
else:
print '<form method="POST" action="ses.py">'
print '<input type="text" name="name">'
print '</form>'
print "</body></html>"
I am new in learning Python and I can't get this to work. Basically,
it asks you to input something and thanks you with the display of what
you entered.
It should remember you. SO when you refresh, it should say that it
remembers you. But it doesn't and shows the input box again.
What could possibly be wrong here?
Thanks in advance!
Fazer
More information about the Python-list
mailing list