8000 SameSite cookies for session don't work for migrated sessions · Issue #29092 · symfony/symfony · GitHub
[go: up one dir, main page]

Skip to content
SameSite cookies for session don't work for migrated sessions #29092
Closed
@rpkamp

Description

@rpkamp

Symfony version(s) affected: 4.2-BETA1

Description
Newly created sessions correctly get a samesite attribute in the cookie when configured in the framework, but once a session is migrated session_regenerate_id() is called, and the custom hook for adding samesite to the cookie in \Symfony\Component\HttpFoundation\Session\Storage\NativeSessionStorage::start is not called, so the new session cookie doesn't have the samesite attribute anymore :(

How to reproduce
In a new Symfony 4.2 project set framework.session.cookie_samesite to lax, and authenticate with the usual suspects (security bundle + form authentication)

Possible Solution
Instead of adding the samesite attribute to the cookie in \Symfony\Component\HttpFoundation\Session\Storage\NativeSessionStorage we could add a listener for kernel.response that would check if there are any session cookies without the samesite attribute and add it when needed.

This does mean we would need the framework.session.samesite_cookie value to that listener somehow, which might not be trivial.

Of course this listener should return early when running on PHP 7.3.

Additional context
None

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

      0