Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Session cookie removed on second request if empty session. #45206

Closed
@tomme87

Description

@tomme87

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

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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions