-
Notifications
You must be signed in to change notification settings - Fork 823
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
ENH Add samesite attribute to cookies. #10335
ENH Add samesite attribute to cookies. #10335
Conversation
Leaving in draft for now because I still need to add unit tests. |
Actually.... I don't think there is a way to test this... none of the unit tests current test against any of the properties of cookies other than the values and whether they're set at all. I don't think there's a way we can test if the cookie's Marking as ready for review. But if anyone has ideas for how we could test this, that'd be awesome. Edit: Steve has pointed out that it should be possible to test with a |
After giving this a go it looks like I can't test cookie attributes in a Changing the way we add cookies to make them more fully mockable would definitely be a valuable enhancement but is out of scope for this PR. I've created an issue (#10338) for that. |
docs/en/02_Developer_Guides/18_Cookies_And_Sessions/01_Cookies.md
Outdated
Show resolved
Hide resolved
docs/en/02_Developer_Guides/18_Cookies_And_Sessions/01_Cookies.md
Outdated
Show resolved
Hide resolved
fd205a1
to
468a6df
Compare
5088070
to
3168d3b
Compare
@emteknetnz Requested changes made. |
docs/en/02_Developer_Guides/18_Cookies_And_Sessions/02_Sessions.md
Outdated
Show resolved
Hide resolved
3168d3b
to
8488833
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Dismiss this stale review
178734f
to
169ceba
Compare
169ceba
to
f1e8f21
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Test locally, works great. Thanks for implementing all the feedback!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just noticed there's a failing unit test - happy to merge once this is fixed
Co-authored-by: pine3ree <[email protected]>
f1e8f21
to
31c974c
Compare
It turns out the |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Merge on green
Sets a default
samesite
attribute on all cookies. Using theLax
value means that we're just setting an explicit value that is identical to the implicit value that was already being used.This PR provides a way to configure both the default value for all cookies and for session cookies separately, as well as giving an extension hook if a specific value is desired for a given cookie.
The extension hook should be removed in the next major in favour of adding a new parameter like what was proposed in #9842 - I've avoided doing that here because the cookie backend is explicitly extensible (with an interface and docs and everything) so adding new parameters here would constitute a breaking change.
The following links may be useful background:
https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Set-Cookie/SameSite
https://www.php.net/manual/en/function.setcookie.php
https://www.php.net/manual/en/function.session-set-cookie-params.php
Parent issue:
Related issue: