Cookie Confusion - How to Set a Cookie

cbhoem at gmail.com cbhoem at gmail.com
Thu May 1 09:02:35 EDT 2008


On Apr 29, 3:35 pm, Aaron Watters <aaron.watt... at gmail.com> wrote:
> > 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+n...


Sorry for the slow replies.  I've been in & out with a sick child.

I'm used to my javascript cookies.  They are automatically written to
a cookie.txt file in a .mozilla dir under my user.  When I say to
'write the cookie file' this is what I was referring to.  I was
expecting my python cookie to automatically get written to the same
file.  I have't seen this happen yet.



More information about the Python-list mailing list