[Tutor] Help with cookies

Danny Yoo dyoo@hkn.eecs.berkeley.edu
Wed, 5 Sep 2001 11:40:38 -0700 (PDT)


On Wed, 5 Sep 2001, Charlie Clark wrote:

> I need to be able to pass a cookie in a url request. I know what the
> cookie should contain and inspection of the cookie module and
> documentation indicates that handling cookies should be
> straightforward but the example does not include sending one in an url
> request. Has anyone experience of this and ideas on how this might be
> done.

I have a silly example of one here:

    http://hkn.eecs.berkeley.edu/~dyoo/python/cookiecounter.py

The important thing is that we send off the cookie before any of the other
headers: otherwise, the browser will ignore the cookie.  I think that the
RFC says something to this effect here:

    http://home.netscape.com/newsref/std/cookie_spec.html



There should be some other examples of cookies on Useless Python.

    http://www.lowerstandard.com/python/pythonsource.html

Hmmm... it might be nice if we had a small searching facility for Useless
Python --- it's getting big!  *grin*