Cookie Confusion - How to Set a Cookie

Aaron Watters aaron.watters at gmail.com
Tue Apr 29 16:35:47 EDT 2008


> Thanks for the code, Aaron.  I will give it a try.
>
> I've been reading some more about cookielib and am not sure whether I
> should use Cookie or cookielib.  This is what I want to do:  a user is
> going to login.  Upon a successful login, I want to write their name
> and date/time of visit to a cookie file. Which is the correct python
> module to use?

Cookie does parsing and generation of cookie strings
for server-side applications like your CGI script.

The cookielib module
is designed for either implementing a client like a web browser
or emulating a client/browser (for web scraping, for example).

I think you want to use Cookie.
The distinction could be made clearer in
the docs, imho.

Also, when you say "write the cookie file" I think you mean
"store the cookie to the client browser".  This should happen
automatically when you send the cookie header to the client
correctly (if the client is configured to cooperate).

  -- Aaron Watters

===
http://www.xfeedme.com/nucular/pydistro.py/go?FREETEXT=default+does+nothing





More information about the Python-list mailing list