Skip to content

[Session] Not possible to set prefix/ttl in RedisSessionHandler settings via DSN #41071

@apfelbox

Description

@apfelbox

Symfony version(s) affected: 5.2.x

Description
The RedisSessionHandler allows to set two options: prefix and ttl.
Unfortunately, it looks like these settings are not properly based in the calling code:

https://github.com/symfony/symfony/blob/5.x/src/Symfony/Component/HttpFoundation/Session/Storage/Handler/SessionHandlerFactory.php#L53-L62

Instead, only the options ["lazy" => true] are passed. The options from the DSN are not parsed for setting up the symfony-side of the config (they are only parsed to configure the redis client itself).

How to reproduce
Use the following DSN to configure your session client: redis://localhost:6379?prefix=ohai_ and it will still use the default prefix sf_s.

The SessionHandlerFactory uses the redis parsing code from symfony/cache, so only the connection is set up with these settings and not the session handler itself.

Possible Solution
The only solution I see right now is to parse the query twice: once for setting up the session handler, once for creating the connection.

Additional context
n/a

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