8000 [HttpFoundation] SessionHandlerFactory doesn't support session.save_path setting of php.ini on NativeFileSessionHandler · Issue #41669 · symfony/symfony · GitHub
[go: up one dir, main page]

Skip to content

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

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
simonchrz opened this issue Jun 11, 2021 · 0 comments

Comments

@simonchrz
Copy link
Contributor
simonchrz commented Jun 11, 2021

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants
0