Support for Same-Site cookies has landed in Firefox 60, but as of Python 3.6 the standard library cookie module doesn't support the SameSite
attribute.
Asked
Active
Viewed 3,547 times
1 Answers
10
Support for the SameSite
attribute was added on April 7, 2018 in Pull Request #6413.
It's possible to monkey-patch older versions to support the attribute:
try:
from http.cookies import Morsel
except ImportError:
from Cookie import Morsel
Morsel._reserved[str('samesite')] = str('SameSite')
Or using six:
from six.moves.http_cookies import Morsel
Morsel._reserved[str('samesite')] = str('SameSite')

Changaco
- 790
- 5
- 12
-
why the `str` around `samesite` and `SameSite`? – user2297550 Nov 01 '18 at 01:57
-
2To ensure compatibility with python 2 when the `unicode_literals` mode is on. – Changaco Nov 01 '18 at 08:05
-
appreciate the clarification; this helped and since i use python 3 i removed the `str` – user2297550 Nov 02 '18 at 11:39