Skip to content

Loosing session data in test environment if session is not used in request #6225

Closed
@maryo

Description

@maryo

If MockFileSessionStorage is used and session data are not used (session is not started). Session data are replaced with an empty array.

For example if user is logged in (authentication token is present in the session) and user goes to a non-existenting page, then the session ID is set from cookies (see TestSessionListener#onKernelRequest) but the session is not started. Then after NotFoundHttpException is thrown, TestSessionListener#onKernelResponse calls Session#save and replaces the session data with an empty array.

In common situations it works becase the session is started when something reads the data from the session. See MockArraySessionStorage#getBag.

I think there should be some condition if the session is started before it saves it.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions