Cookies / CGI
Timothy O'Malley
timo at alum.mit.edu
Sun May 28 00:10:58 EDT 2000
hola.
For what it's worth:
In article <Pine.LNX.4.21.0005241111360.3750-100000 at fep132.fep.ru>,
Oleg Broytmann <phd at phd.russ.ru> wrote:
> # ----- create -----
> #! /usr/local/bin/python -O
>
> def set_cookie():
> import time
> t = time.gmtime(time.time())
> t = (t[0] + 10,) + t[1:] # add 10 years :)
>
> import Cookie
> cookie = Cookie.Cookie()
>
> cookie["id"] = str(1024)
> cookie["id"]["expires"] = time.strftime("%a, %d-%b-%Y %T GMT", t)
You don't have to format the time string yourself. Cookie.py will
do it for you. Just set the value to the number of seconds:
cookie["id"]["expires"] = 10 * 365 * 24 * 3600
More information about the Python-list
mailing list