Cookies

Carsten Haese carsten.haese at gmail.com
Wed Dec 30 11:43:02 EST 2009


Victor Subervi wrote:
> I've revised the code thus:
> 
>   cookie = os.environ.has_key('HTTP_COOKIE')
>   if not cookie:
>     cookie = Cookie.SimpleCookie()
>     cExpires, cPath, cComment, cDomain, cMaxAge, cVersion = myCookie()
>     cookie['lastvisit'] = str(time.time())
>     cookie['lastvisit']['expires'] = cExpires
>     cookie['lastvisit']['path'] = cPath
>     cookie['lastvisit']['comment'] = cComment
>     cookie['lastvisit']['domain'] = cDomain
>     cookie['lastvisit']['max-age'] = cMaxAge
>     cookie['lastvisit']['version'] = cVersion
>     print cookie
>     cookieFlag = 'new'
>  
> Unfortunately, this still prints "new" for the cookieFlag no matter how
> many times I refresh. Please advise.

That tells me nothing, because once again you're not posting your
complete code.

Anyway, the likely answer is that you guessed incorrectly. As I said
before, you need to make sure that the cookie is printed as part of the
page headers. I'll give you one last hint: The page header is where
you're printing the "Content-type" line.

--
Carsten Haese
http://informixdb.sourceforge.net




More information about the Python-list mailing list