<div class="gmail_quote">On Tue, Dec 29, 2009 at 3:43 PM, Carsten Haese <span dir="ltr"><<a href="mailto:carsten.haese@gmail.com">carsten.haese@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
<div><div></div><div class="h5">Victor Subervi wrote:<br>
> Hi;<br>
> I have these lines:<br>
><br>
>   cookie = os.environ.get('HTTP_COOKIE')<br>
>   if not cookie:<br>
>     cookie = Cookie.SimpleCookie()<br>
>     cExpires, cPath, cComment, cDomain, cMaxAge, cVersion = myCookie()<br>
>     cookie['lastvisit'] = str(time.time())<br>
>     cookie['lastvisit']['expires'] = cExpires<br>
>     cookie['lastvisit']['path'] = cPath<br>
>     cookie['lastvisit']['comment'] = cComment<br>
>     cookie['lastvisit']['domain'] = cDomain<br>
>     cookie['lastvisit']['max-age'] = cMaxAge<br>
>     cookie['lastvisit']['version'] = cVersion<br>
>     cookieFlag = 'new'<br>
>   else:<br>
>     cookie = Cookie.SimpleCookie(cookie)<br>
>     cookieFlag = 'old'<br>
>   print '''Content-Type: text/html\r\n<br>
> <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"><br>
> <html><br>
> '''<br>
>   print cookieFlag<br>
><br>
> cookieFlag prints 'new'. Every time. Even when I refresh. I've imported<br>
> Cookie. I've followed the tutorials :-} I've already been through my<br>
> problem with trying to find the cookies on this computer. The fact that<br>
> I'm using gmail is proof that cookies are enabled. I have also tried:<br>
> cookie = os.environ.has_key('HTTP_COOKIE')<br>
> Please advise.<br>
<br>
</div></div>You apparently haven't followed the tutorials carefully enough. You do<br>
know that a cookie is a piece of information that's stored in your<br>
browser, don't you? So tell me, which of the above lines of code do you<br>
suppose is responsible for informing your browser of the cookie's contents?<br></blockquote><div><br></div></div>This one:<br><br>cookie = SimpleCookie()<br><br>In the tutorial found here, for example:<br><br><a href="http://www.doughellmann.com/PyMOTW/Cookie/index.html">http://www.doughellmann.com/PyMOTW/Cookie/index.html</a><br>
<br>I read the following:<br><br><snip><br>Cookies are used as state management, and as such as usually set by the server to be stored and returned by the client. The most trivial example of creating a cookie looks something like:<br>
<br>import Cookie<br><br>c = Cookie.SimpleCookie()<br>c['mycookie'] = 'cookie_value'<br>print c<br><br>The output is a valid Set-Cookie header ready to be passed to the client as part of the HTTP response:<br>
<br>$ python Cookie_setheaders.py<br>Set-Cookie: mycookie=cookie_value<br></snip><br><br>Do not the printout words "Set-cookie" indicate the cookie has been set? Furthermore, none of the tutorials I have found state anything differently. Another example is found here:<br>
<br><a href="http://webpython.codepoint.net/cgi_set_the_cookie">http://webpython.codepoint.net/cgi_set_the_cookie</a><br><br>Please advise.<br>TIA,<br>beno<br>