classification
Title: cookielib.LWPCookieJar.save() doesn't save cookies
Type: behavior Stage: resolved
Components: Library (Lib) Versions: Python 2.5
process
Status: closed Resolution: not a bug
Dependencies: Superseder:
Assigned To: Nosy List: mcencula
Priority: normal Keywords:

Created on 2011-02-23 20:50 by mcencula, last changed 2011-02-28 14:18 by orsenthil. This issue is now closed.

Files
File name Uploaded Description Edit
cookieexample2.py mcencula, 2011-02-23 20:50 Sample code demonstrating cookielib.LWPCookieJar.save() issue
Messages (2)
msg129223 - (view) Author: Mike Cencula (mcencula) Date: 2011-02-23 20:50
I'm trying to use cookielib.LWPCookieJar.save() to save cookies from a website.  The cookie file is created with a header line, but the cookies are not stored.  Example program attached.

Python version:
2.5.2 (r252:60911, Jan 24 2010, 14:53:14)

Running on Debian lenny as a guest on Virtualbox

Output from the attached file pasted below:
------------
mike@debian:~$ python cookieexample2.py
Here are the headers of the page :
Server: none
Content-Type: text/html
Pragma: no-cache
Cache-Control: no-cache
Expires: Tue, 04 Dec 1993 21:29:02 GMT
Vary: Accept-Encoding
Date: Wed, 23 Feb 2011 20:43:55 GMT
Transfer-Encoding:  chunked
Connection: close
Connection: Transfer-Encoding


These are the cookies we have received so far :
0   :   <Cookie BIGipServerdiy_pool=604317450.20480.0000 for www.diy.co.uk/>
1   :   <Cookie BIGipServerdiy_pool=637871882.20480.0000 for www.diy.com/>
2   :   <Cookie DYN_USER_CONFIRM=1ab776eae0bf5661a2955c6ec7858439 for www.diy.com/>
3   :   <Cookie DYN_USER_ID=1619150879 for www.diy.com/>
4   :   <Cookie JSESSIONID=OVHJMMEHW4LOQCRHAWVCFFIKE2C0YIV0 for www.diy.com/>
mike@debian:~$

Contents of cookie.lwp afterward:
------------
mike@debian:~$ cat cookies.lwp
#LWP-Cookies-2.0
mike@debian:~$

Behavior is nearly identical using cookielib.MozillaCookieJar except the headers are different in the saved cookie file.  Cookies themselves are not saved.

I am new to Python, so I hope this is not user error.
msg129224 - (view) Author: Mike Cencula (mcencula) Date: 2011-02-23 21:12
User error indeed.  Adding ignore_discard=True, ignore_expires=True cured the issue.

Thank you.
History
Date User Action Args
2011-02-28 14:18:05orsenthilsetresolution: not a bug
stage: resolved
2011-02-23 21:12:29mcenculasetstatus: open -> closed

messages: + msg129224
2011-02-23 20:50:24mcenculacreate