Νίκος Αλεξόπουλος <nikos.gr...@gmail.com> writes:

>
> # initialize cookie and retrieve cookie from clients browser
> cookie = cookies.SimpleCookie( os.environ['HTTP_COOKIE'] )
>
> if cookie.get('ID') is not None:
>       cookieID = cookie['ID'].value
> else:
>       cookieID = random.randrange(0, 9999)
>       cookie['ID'] = cookieID
>       cookie['ID']['domain'] = ".superhost.gr"
>       cookie['ID']['path'] = '/'
>       cookie["ID"]["expires"] = 60*60*24*365          # this cookie will 
> expire in a year
>
As Ian already has told you (but apparently you didn't pay attention to), your 
expires is wrong. So if your cookies disappear you should get this right first.

from datetime import datetime, timedelta
expiretime = datetime.utcnow() + timedelta(days=365)

cookie["ID"]["expires"] = expiretime.strftime("%a, %d %b %Y %H:%M:%S GMT")
-- 
Piet van Oostrum <p...@vanoostrum.org>
WWW: http://pietvanoostrum.com/
PGP key: [8DAE142BE17999C4]
-- 
https://mail.python.org/mailman/listinfo/python-list

Reply via email to