:
This message was edited by Moderator at 2003-4-7 8:44:42
: :
This message was edited by andohung at 2003-4-5 22:30:30
: : I tried to create a Cookie in python and try to test it if its in the os.environ.
: : but the Cookie wasn't created or detected afterwards...
: : here is my code.
: :
: : C = Cookie.SimpleCookie()
: : C["username"] = tusername
: : C["validated"] = tvalidated
: :
: : if os.environ.has_key("HTTP_COOKIE"):
: : cookie_exist = "yes"
: : else:
: : cookie_exist = "no"
: :
: : print cookie_exist
: :
: : anyone pls help!
:
: Well, what did you do with the cookie once you created it? If you don't include it in the http headers of a webpage, it will never be set anywhere. Cookies are used for state management in web browsers. You set them by including Set-Cookie directives in the http headers of a webpage, and the browser returns them when it requests that page again from the server.
:
: Here's a simple script I just wrote and dropped in my Apache server's cgi-bin:
:
:
: #!C:\Python22\python.exe
:
: import Cookie, cgi, cgitb, os
:
: cgitb.enable()
:
: print 'Content-type: text/plain'
:
: c = Cookie.SimpleCookie()
: c['username'] = 'bobjones'
: c['password'] = 'foobar'
:
: print c
:
: print # end of headers
:
: for k, v in os.environ.items():
: print k, "=", v
:
:
: The first time I viewed it, there was no HTTP_COOKIE variable in the results because the cookie wasn't set until I viewed the page. Reloading the page, however, included the HTTP_COOKIE variable because my browser was then able to return it to the server.
:
:
:
infidel
:
:
:
:
Can you make websites with Python?!
Id think that the regualr HTML
Would be a lot better =P