-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
[HttpKernel] Send new session cookie from AbstractTestSessionListener after session invalidation #26157
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
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@rpkamp would you mind adding a test case please? |
@@ -45,6 +47,7 @@ public function onKernelRequest(GetResponseEvent $event) | |||
|
|||
if ($cookies->has($session->getName())) { | |||
$session->setId($cookies->get($session->getName())); |
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.
I'd suggest to move this line below the current next one, and write it as:
$session->setId($this->initialSessionId)
cf89a22
to
4e2924e
Compare
@nicolas-grekas I've added the test, as requested 😃 |
… after session invalidation
d97f857
to
98f5d53
Compare
nicolas-grekas
approved these changes
Feb 19, 2018
Thank you @rpkamp. |
nicolas-grekas
added a commit
that referenced
this pull request
Feb 19, 2018
…ionListener after session invalidation (rpkamp) This PR was merged into the 3.4 branch. Discussion ---------- [HttpKernel] Send new session cookie from AbstractTestSessionListener after session invalidation When we call `\Symfony\Component\HttpFoundation\Session\Session::invalidate` the session will be emptied and given a new ID, however, since it is empty this `AbstractTestSessionListener` will not send a new cookie to the user, so the user is not caught up to the latest session ID and will re-generate a session with the old session ID on a new visit. Thus, we the sessionID has changed during a request we must always send a new cookie with the new sessionID, even though the session is empty. This behaviour is also what is shown in production (non-test) mode. | Q | A | ------------- | --- | Branch? | master | Bug fix? | yes | New feature? | no | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | N/A | License | MIT Commits ------- 98f5d53 [HttpKernel] Send new session cookie from AbstractTestSessionListener after session invalidation
nicolas-grekas
added a commit
that referenced
this pull request
Jul 1, 2018
…ith CookieClearingLogoutHandler (thewilkybarkid) This PR was squashed before being merged into the 3.4 branch (closes #27659). Discussion ---------- [HttpKernel] Make AbstractTestSessionListener compatible with CookieClearingLogoutHandler | Q | A | ------------- | --- | Branch? | 3.4 | Bug fix? | yes | New feature? | no | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | | License | MIT | Doc PR | #26157 started to send a new cookie in `AbstractTestSessionListener`, but is incompatible with `CookieClearingLogoutHandler` as it overrides its `Set-Cookie` by setting a new cookie (breaking my test that checked to see that the cookie was removed after a log out). Commits ------- f54d969 [HttpKernel] Make AbstractTestSessionListener compatible with CookieClearingLogoutHandler
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
When we call
\Symfony\Component\HttpFoundation\Session\Session::invalidate
the session will be emptied and given a new ID, however, since it is empty thisAbstractTestSessionListener
will not send a new cookie to the user, so the user is not caught up to the latest session ID and will re-generate a session with the old session ID on a new visit.Thus, we the sessionID has changed during a request we must always send a new cookie with the new sessionID, even though the session is empty.
This behaviour is also what is shown in production (non-test) mode.