-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
session.gc_probability being over written by the kernel #21641
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
The default value for the # config.yml
framework:
session:
gc_probability: null to keep using the value defined in you php.ini file. |
Debian's default is still 0. Debian has a script that clears the sessions periodically. But unfortunately this one only clears in the default directory. If you change it you either have to change the script or set the flag to 1 |
Why not look at the value in php.ini and if it is 0 set it as 1 else use the value? Either way, this should be reflected in the documentation. |
None of the components looks at how something is set. You have to set it explicitly or leave alone which means that default value is used. |
from @ogizanagi:
This is the way to go for sure, but this REALLY needs to be updated in the documentation at http://symfony.com/doc/current/components/http_foundation/session_configuration.html#configuring-garbage-collection so that in future users will be able to understand how gc works now. |
@MicWit : I agree. It's documented in the FrameworkBundle config reference page, though (the default value). But maybe you could try to submit a PR to the |
Done, though I'm not 100% on the documentation code, the pull request is at symfony/symfony-docs#7514 if you want a look? I also couldn't work out links in it (I looked at some other source code but there was no source for the link etc) |
Closing it in favor the doc PR symfony/symfony-docs#7514 |
I am trying to implement sessions on the database using https://github.com/shapecode/doctrine-session-handler-bundle. One of the things I need to test is that sessions are being cleaned up using the gc method. So I changed session.gc_probability in php.ini from the red hat default of 1 (out of 1000, most are out of 100) to 1000, to make it try and clear every time. When it wasn't I started echoing the variable in app_dev.php to see what was going on, and found it was being reset somewhere in
$response = $kernel->handle($request);
In order to test this, you can just change the lines (in a new install of Symfony) from:
to:
and look at the results. You should end up with 10001, the 1000 being the first time it is echoed (or whatever value you set this to in php.ini) and then the second time it has been changed to 1.
According to the Symfony documentation at http://symfony.com/doc/current/components/http_foundation/session_configuration.html#configuring-garbage-collection, it uses the values in php.ini to set the chances of gc happening.
This would be ok if it worked properly, as in dev we could set it to 100% of the time to test expiry of sessions (for example from the database). As far as I am aware, it should never change this variable from the value it is set to in php.ini.
The text was updated successfully, but these errors were encountered: