-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
Symfony Session doesn't work if set handler_id via environment variable #45202
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
Comments
Tested in 5.4.5. Same issue. |
You can not switch the session handler based on an env variable as it can not be changed at runtime, it requires a whole cache clear. You would need to switch to a parameter instead of env var. There are some discussion about static vs runtime env vars here: #40794 |
Closing here as explained by @alexander-schranz. Thank you for understanding. |
@alexander-schranz thanks for your reply. The whole purpose of setting the session handler via an env var is to keep this setting variable and isolated from the version control software. If I set the session handler using a parameter in framework.yaml I would have to keep the entire file away from my control version system. I need to keep framework.yaml tracked by git with the ability to switch between session handlers without messing with deploys. Is that possible? Thanks again. |
It is not possible as env variables are designed to be used only for configurations which do not require a cache clear. For using env variables for configs which do require a cache clear the linked issue is about it (#40794). You could still use the parameters.yml/parameters.yml.dist like it was in symfony 3/2: see comment here: #40794 (comment) See also the linked presentation here where nicolas did talk about runtime parameters and config parameters and so on: #40794 (comment) As you see the last comment of the linked issue is "Help wanted", so symfony is open here for a pull request to introduce a special env resolver to achieve this things e.g.: #40794 Until you need as said go with something else, a parameters.yml or some hack in your |
@alexander-schranz thank you very much. I will be back on this if I find a proper solution. |
Symfony version(s) affected
5.3.0/5.4.5
Description
Symfony throws
Unsupported Connection: "session.handler.native_file"
if you sethandler_id
inconfig/packages/framework.yaml
tosession.handler.native_file
via.env
variable.I want to have the ability to switch between different session handlers in my application, so I added a .env variable named "SESSION_HANDLER" to set
handler_id
inframework.yaml
. I want to support several session handlers, including native_file.If I set a Redis URL in my SESSION_HANDLER .env var, it works perfectly and uses my Redis node as the session handler. But, if I set SESSION_HANDLER to
session.handler.native_file
, I got:How to reproduce
Add
SESSION_HANDLER
var in.env
and set it tosession.handler.native_file
:.env
:Set handler_id via .env var in
framework.yaml
:config/packages/framework.yaml
:internal_server_error.txt
Possible Solution
No response
Additional Context
No response
The text was updated successfully, but these errors were encountered: