Skip to content

"Cannot change the ID of an active session." after upgrading to 5.4 #44553

@devnix

Description

@devnix

Symfony version(s) affected

5.4.0, 5.4.1

Description

We have a legacy application that we are slowly migrating to Symfony, which we did following this guide with good results since 5.0: https://symfony.com/doc/current/session/php_bridge.html

Since we upgraded to 5.4.0 from 5.3.*, we are observing a Cannot change the ID of an active session. intermitently.

How to reproduce

I've been able to reproduce in an isolated project: https://github.com/devnix/symfony-sessions-messed-up

master branch is running 5.4.* and branch 5.3 is showing how it works.

Possible Solution

I've been able to track down the code affecting the sessions this way here: b3e4f66

https://github.com/symfony/symfony/blob/v5.4.0/src/Symfony/Component/HttpKernel/EventListener/AbstractSessionListener.php#L72-L87
https://github.com/symfony/symfony/blob/v5.4.0/src/Symfony/Component/HttpKernel/EventListener/AbstractSessionListener.php#L136-L183

Monkey patching the class without these portions of code makes it work again.

I understand that this is a neat solution for new runtimes like Roadrunner, but it's breaking compatibility with how sessions worked. Maybe the solution would be to be able to opt-in to this functionality? Should the documentation about migrating legacy applications be updated?

Additional Context

No response

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