Getting and Setting Cookies

John J. Lee jjlee at reportlab.com
Wed Jul 19 17:22:06 EDT 2006


"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).


John



More information about the Python-list mailing list