Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 4e2924e

Browse filesBrowse files
rpkampnicolas-grekas
authored andcommitted
[HttpKernel] Send new session cookie from AbstractTestSessionListener after session invalidation
1 parent 6b51add commit 4e2924e
Copy full SHA for 4e2924e

File tree

Expand file treeCollapse file tree

1 file changed

+5
-2
lines changed
Filter options
Expand file treeCollapse file tree

1 file changed

+5
-2
lines changed

‎src/Symfony/Component/HttpKernel/EventListener/AbstractTestSessionListener.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/HttpKernel/EventListener/AbstractTestSessionListener.php
+5-2Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,8 @@
2929
*/
3030
abstract class AbstractTestSessionListener implements EventSubscriberInterface
3131
{
32+
private $initialSessionId;
33+
3234
public function onKernelRequest(GetResponseEvent $event)
3335
{
3436
if (!$event->isMasterRequest()) {
@@ -44,7 +46,8 @@ public function onKernelRequest(GetResponseEvent $event)
4446
$cookies = $event->getRequest()->cookies;
4547

4648
if ($cookies->has($session->getName())) {
47-
$session->setId($cookies->get($session->getName()));
49+
$this->initialSessionId = $cookies->get($session->getName());
50+
$session->setId($this->initialSessionId);
4851
}
4952
}
5053

@@ -66,7 +69,7 @@ public function onKernelResponse(FilterResponseEvent $event)
6669
$session->save();
6770
}
6871

69-
if ($session instanceof Session ? !$session->isEmpty() : $wasStarted) {
72+
if ($session instanceof Session ? !$session->isEmpty() || $session->getId() !== $this->initialSessionId : $wasStarted) {
7073
$params = session_get_cookie_params();
7174
$event->getResponse()->headers->setCookie(new Cookie($session->getName(), $session->getId(), 0 === $params['lifetime'] ? 0 : time() + $params['lifetime'], $params['path'], $params['domain'], $params['secure'], $params['httponly']));
7275
}

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.