Shinyshell Community Forums > Coding > Cookies in Python? |
||||||
Sign Up | Member List | New Posts | Help |
[1]
January 29 02009, 07:40 GMT | ||||
Nick^ merciful justice Location: Brisbane, Australia Post count: 78 |
The other day I decided that I would completely code PokéNova in Python, which would have been a great decision, if I actually half-knew how to code it. I realised that the thing I was having the most trouble with was cookies - how to set, destroy and check (the value of) them.
So, can someone please tell me how to do it? And if they are really, really nice, could they please include an example script in their post? Also, I'd like to know how import works, and how I can make my own modules and set it up so that I can import them in my scripts. Thanks! ______________________________ Lazurane |
January 29 02009, 21:33 GMT | ||||
lec** Supra stultitiam Location: Varaždin, Croatia Post count: 173 |
import os There is probably a way to set cookies too using the Cookie module, but I prefer using the HTTP way directly, since my templating system doesn't print stuff right away, rather after I have generated all the content (a requirement of FCGI) print "Set-Cookie: userid=%s; expires=%s" % (cookie_userid, cookie_expiry) |
February 09 02009, 09:18 GMT | ||||
Nick^ merciful justice Location: Brisbane, Australia Post count: 78 |
And to destroy/expire cookies (on logout for example, would the code be like this?:
cookie_userid = false ______________________________ Lazurane |
February 09 02009, 13:15 GMT | ||||
lec** Supra stultitiam Location: Varaždin, Croatia Post count: 173 |
Since cookies use timestamps when you're setting them, not relative counts of seconds, an expiry time of 0 will probably work better.
|
[1]
Forum Information |
||||||||||
|