[Tutor] Fun with Cookies

Alex Ezell aezell at gmail.com
Fri Sep 7 20:28:34 CEST 2007

Hi all,
I am trying to create a cookie and send it a long with a request.

I searched the archives and found this code from Kent Johnson:

import cookielib, urllib2

cj = cookielib.CookieJar()
cookie = cookielib.Cookie(...your cookie data here...)

opener = urllib2.build_opener(urllib2.HTTPCookieProcessor(cj))

data = urllib2.urlopen(...).read()

It seemed to solve a problem I was having with SimpleCookie(), but I
cannot figure out what I should put where Kent has written "...your
cookie data here...". I have tried strings, SimpleCookie instances,
etc. and I always get this error on that line:

__init__() takes at least 17 arguments (2 given)

Thanks for your time.

Alex Ezell

More information about the Tutor mailing list