Skip to content

Default SESSION_COOKIE_SAMESITE to "Lax" - #5956

Closed
kodareef5 wants to merge 1 commit into
pallets:mainfrom
kodareef5:default-samesite-lax
Closed

kodareef5 wants to merge 1 commit into
pallets:mainfrom
kodareef5:default-samesite-lax

Conversation

@kodareef5

Copy link
Copy Markdown

Change the default value of SESSION_COOKIE_SAMESITE from None to "Lax".

When set to None, Flask does not include the SameSite attribute on session cookies, relying on browser defaults. While modern browsers default to Lax behavior when the attribute is absent, setting it explicitly ensures consistent CSRF defense-in-depth across all browser versions, including older ones that do not apply the Lax default.

Django has defaulted to "Lax" since 2.1 (2018). Express.js and Rails also default to Lax. This aligns Flask with the ecosystem standard.

Applications that require cross-site cookie behavior can set SESSION_COOKIE_SAMESITE to None (with SESSION_COOKIE_SECURE=True).

All existing tests pass with this change (486 passed, 0 regressions).

Change the default value of SESSION_COOKIE_SAMESITE from None to
"Lax". When set to None, Flask does not include the SameSite
attribute on session cookies, relying on browser defaults.

While modern browsers default to Lax behavior when the attribute is
absent, setting it explicitly ensures consistent CSRF defense across
all browser versions, including older ones that do not apply the Lax
default.

Django has defaulted to "Lax" since 2.1 (2018). This aligns Flask
with the ecosystem standard.

Applications that require cross-site cookie behavior can set
SESSION_COOKIE_SAMESITE to None (with SESSION_COOKIE_SECURE=True).
@davidism davidism closed this Mar 23, 2026
@github-actions github-actions Bot locked as resolved and limited conversation to collaborators Apr 6, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants