Title: MozillaCookieJar does not handle session cookies
Type: behavior Stage:
Components: Library (Lib) Versions: Python 3.6, Python 3.5, Python 3.4
Status: open Resolution:
Dependencies: Superseder:
Assigned To: Nosy List: jdetrey, orsenthil, piotr.dobrogost
Priority: normal Keywords: patch

Created on 2013-02-08 21:23 by piotr.dobrogost, last changed 2015-01-07 14:11 by jdetrey.

File name Uploaded Description Edit
session-cookies.patch jdetrey, 2015-01-07 10:33 patch review
session-cookies-test.patch jdetrey, 2015-01-07 14:11 review
Messages (4)
msg181703 - (view) Author: Piotr Dobrogost (piotr.dobrogost) Date: 2013-02-08 21:23
It seems there's no information on how should session cookies be stored in the Netscape/Mozilla's cookies.txt file with regard to expiry time - see Maybe Netscape has not been saving such cookies at all thus this lack of specification? Nevertheless, both wget and curl use 0 as expiry time to denote session cookies; it works both when reading cookies from file and writing to file. However Python's MozillaCookieJar's class uses empty string for the same purpose which makes it incompatible both with wget and curl - see

I propose to make a change in implementation of MozillaCookieJar class and treat cookies with 0 set as expiry time as session cookies both when reading from a file and writing to a file.

Motivation for this bug report comes from the following question on Stack Overflow -
msg182501 - (view) Author: Piotr Dobrogost (piotr.dobrogost) Date: 2013-02-20 13:05
I could try to write a patch with some help if there was any chance it might be accepted. Where do I start?
msg233574 - (view) Author: Jérémie Detrey (jdetrey) * Date: 2015-01-07 10:33
Dear all,

Here is a small tentative patch for fixing this issue.

Expiry times for session cookies are now written as "0", and both "0" and "" are parsed as valid expiry times for session cookies.

msg233579 - (view) Author: Jérémie Detrey (jdetrey) * Date: 2015-01-07 14:11
Hi again,

Attached is a patch for adding test cases to test_cookiejar.

Date User Action Args
2015-01-07 14:11:05jdetreysetfiles: + session-cookies-test.patch

messages: + msg233579
2015-01-07 10:33:05jdetreysetfiles: + session-cookies.patch
versions: + Python 3.6
nosy: + jdetrey

messages: + msg233574

keywords: + patch
2013-02-20 13:05:05piotr.dobrogostsetmessages: + msg182501
2013-02-10 19:26:35orsenthilsetnosy: + orsenthil
2013-02-08 21:23:23piotr.dobrogostcreate