问题
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.
回答1:
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')
来源:https://stackoverflow.com/questions/50813091/how-do-i-set-the-samesite-attribute-of-http-cookies-in-python