-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
Closed
Description
Symfony version(s) affected
5.4.3
Description
After creating a session it always get removed the next request.
Looks like this started happening after #41390
If you look at
symfony/src/Symfony/Component/HttpKernel/EventListener/AbstractSessionListener.php
Lines 155 to 163 in 3cbef85
if ($requestSessionCookieId && $session->isEmpty()) { | |
$response->headers->clearCookie( | |
$sessionName, | |
$sessionCookiePath, | |
$sessionCookieDomain, | |
$sessionCookieSecure, | |
$sessionCookieHttpOnly, | |
$sessionCookieSameSite | |
); |
It removes cookie if session is empty. My session is always empty. I just need to have a session, even if it's empty.
How to reproduce
Start a session without data and the cookie will get removed immediately after.
Possible Solution
Never remove the cookie unless it's expired or removed explicitly?
Additional Context
Discussion in #44634 looks relevant