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

Skip to content

[HttpFoundation] SessionHandlerFactory doesn't support session.save_path setting of php.ini on NativeFileSessionHandler #41669

Closed
@simonchrz

Description

@simonchrz

Symfony version(s) affected: >=4.4

Description
By introducing the great Symfony\Component\HttpFoundation\Session\Storage\Handler\SessionHandlerFactory it is possible to configure session handler via DSN. But if I want to use the NativeFileSessionHandler to use configured session.save_path of php.ini, it doesn't work as expected because the $savePath constructor param is an empty string (and not NULL) by using "file://" as DSN.

How to reproduce
SessionHandlerFactory::createHandler('file://');

$savePath will be an empty string
https://github.com/symfony/symfony/blob/4.4/src/Symfony/Component/HttpFoundation/Session/Storage/Handler/NativeFileSessionHandler.php#L33

Possible Solution

something like

$savePath = substr('file://', 7);
return new StrictSessionHandler(new NativeFileSessionHandler($savePath === '' ? null: $savePath));

instead of

return new StrictSessionHandler(new NativeFileSessionHandler(substr($connection, 7)));

Additional context

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