[Tutor] I sure do love cookies.

Kent Johnson kent37 at tds.net
Sat Jul 2 03:16:25 CEST 2005

D. Hartley wrote:
> Anyone have a good (*simple*) tutorial on making/sending cookies via
> python? (i.e., not receiving/messing with them).

The problem is, what you have to do is not a usual use of cookies. From the client side you usually just get the cookies from the host and echo them back in a new request.

What I did was,
- create a new cookielib.Cookie
- add the cookie to the CookieJar
- make a request the same way as when I was collecting cookies

To create the new Cookie it might help to look at the source for cookielib (Lib\cookielib.py), the Cookie constructor doesn't seem to be documented anywhere.

To figure out the values for the Cookie constructor it might help to look at one of the cookies you already have.


More information about the Tutor mailing list