Cookies

Carsten Haese carsten.haese at gmail.com
Tue Dec 29 15:43:01 EST 2009


Victor Subervi wrote:
> Hi;
> I have these lines:
> 
>   cookie = os.environ.get('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
>     cookieFlag = 'new'
>   else:
>     cookie = Cookie.SimpleCookie(cookie)
>     cookieFlag = 'old'
>   print '''Content-Type: text/html\r\n
> <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
> <html>
> '''
>   print cookieFlag
> 
> cookieFlag prints 'new'. Every time. Even when I refresh. I've imported
> Cookie. I've followed the tutorials :-} I've already been through my
> problem with trying to find the cookies on this computer. The fact that
> I'm using gmail is proof that cookies are enabled. I have also tried:
> cookie = os.environ.has_key('HTTP_COOKIE')
> Please advise.

You apparently haven't followed the tutorials carefully enough. You do
know that a cookie is a piece of information that's stored in your
browser, don't you? So tell me, which of the above lines of code do you
suppose is responsible for informing your browser of the cookie's contents?

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




More information about the Python-list mailing list