Python: Persistent cookie, generate `expires` field -


i'm trying generate text persistent cookie in simple python web application.

i'm having trouble finding way generate expires field. text format field complicated, , i'd rather not write code generate myself.

is there in python help? i've cooked @ docs cookie , cookielib , seem handle lot of cookie business, except generating expires field

i think want this:

import cookie, datetime, uuid ck = cookie.simplecookie()  ck['session'] = str(uuid.uuid4()) ck['session']['domain'] = 'foo.com' ck['session']['path'] = '/' expires = datetime.datetime.utcnow() + datetime.timedelta(days=30) # expires in 30 days ck['session']['expires'] = expires.strftime("%a, %d %b %y %h:%m:%s gmt")  >>> print ck.output() set-cookie: session=9249169b-4c65-4daf-8e64-e46333aa5577; domain=foo.com; expires=mon, 01 aug 2011 07:51:53 gmt; path=/ 

Comments

Popular posts from this blog

c# - SharpSVN - How to get the previous revision? -

c++ - Is it possible to compile a VST on linux? -

url - Querystring manipulation of email Address in PHP -