Getting and Setting Cookies

Vlad Dogaru ddvlad at gmail.com
Thu Jul 20 03:38:41 EDT 2006


John J. Lee wrote:
> "Vlad Dogaru" <ddvlad at gmail.com> writes:
> [...]
> > I am trying to write a simple login script. I understand (or rather I
> > think I understand) how to set a cookie with the Cookie module. My
> > problem is getting the cookies that are currently set. How can I do
> > that?
>
> You still haven't explicitly said that you're writing server-side
> code.  If you are:
>
> IIRC, you .load() it from the HTTP header value, then you use it as a
> mapping (though, oddly, that seems undocumented, except in the
> "Example" section of the docs).  A working CGI-based example (written
> in a rather retro style for ease of deployment):
>
> http://codespeak.net/svn/wwwsearch/ClientCookie/trunk/cookietest.cgi
>
>
> If you want to iterate over all cookies using module Cookie (that
> script does not), use .keys(), .values() or .items() on your
> SimpleCookie instance (it's also a little odd that instances of class
> SimpleCookie do not represent a single cookie, but a collection of
> cookies).

That's pretty much what I was trying to find out. Thanks for the
pointer.

Vlad




More information about the Python-list mailing list