Skip to content

Commit 943a26a

Browse files
Merge branch '5.4' into 6.0
* 5.4: [Serializer] Add missing types to FormErrorNormalizer [HttpFoundation] Fix deps minor #47299 [Console] fix expected command name order with mixed integer and string namespaces (xabbuh) [HttpFoundation] Fix tests on PHP 8.2 fix expected command name order with mixed integer and string namespaces [Serializer] Add missing types to BackedEnumNormalizer Do not send deleted session cookie twice in the response
2 parents 20ca455 + 7dee7f0 commit 943a26a

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

EventListener/AbstractSessionListener.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -153,6 +153,11 @@ public function onKernelResponse(ResponseEvent $event)
153153

154154
$isSessionEmpty = ($session instanceof Session ? $session->isEmpty() : empty($session->all())) && empty($_SESSION); // checking $_SESSION to keep compatibility with native sessions
155155
if ($requestSessionCookieId && $isSessionEmpty) {
156+
// PHP internally sets the session cookie value to "deleted" when setcookie() is called with empty string $value argument
157+
// which happens in \Symfony\Component\HttpFoundation\Session\Storage\Handler\AbstractSessionHandler::destroy
158+
// when the session gets invalidated (for example on logout) so we must handle this case here too
159+
// otherwise we would send two Set-Cookie headers back with the response
160+
SessionUtils::popSessionCookie($sessionName, 'deleted');
156161
$response->headers->clearCookie(
157162
$sessionName,
158163
$sessionCookiePath,

0 commit comments

Comments
 (0)