Skip to content

"None" Value Not Supported in SameSite Directive in setcookie() #592

@pycarus

Description

@pycarus

Hello,

The SameSite cookie directive has three options: Strict, Lax and None:

https://developer.mozilla.org/en-US/docs/Web/HTTP/Cookies#SameSite_cookies
https://tools.ietf.org/id/draft-ietf-httpbis-rfc6265bis-03.html#rfc.section.5.3.7

Web.py's setcookie() function ignores the "None" value and regards it as equivalent to not setting a value:
https://github.com/webpy/webpy/blob/master/web/webapi.py#L530

As browsers migrate to SameSite=Lax by default (Chrome from Feb 4, 2020), setting SameSite to "None" is now the only way to support cookies in cross-site requests.

https://www.chromestatus.com/feature/5088147346030592

Line 530 in webapi.py (https://github.com/webpy/webpy/blob/master/web/webapi.py#L530)

should be changed to:

if samesite and samesite.lower() in ("strict", "lax", "none"):

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions