I use Symfony session to store, and retrieve, the language selected by users on a splash page. If they have no language set they are redirected to the splash directly. This behavior works as expected.
Unfortunately when I clear the cache I got issues with it (I use php app/console cache:clear --env=prod
command). Users can access one page then on any click they are redirected to the splash. Afterwards, even if they choose a language they will not be able to go any further than the homepage, any click will redirect again to splash.
If I delete the cache folder manually the error will not occur.
My session related configuration is the following:
framework:
session:
handler_id: ~
gc_probability: 0
I have no session folder into my cache directory. I can find my session files into my site tmp folder (session id and content match the user session cookie and language choice). They are preserved after cache:clear command but it seems Symfony cannot get values from those files anymore. Also, no new session file is created for those user, and it seems new language choice cannot be written anywhere.
I don't have the error on my local development environment (improved Homestead) but I have it on all my others environments (dev, staging, production)
Using $session->invalidate(); on the splash page will fix the issue. But I would like to understand why it occurs. Any ideas ?
gc_probability
to 0 ? And i suppose you override thesession.save_path
? If you have different behavior between environmental checks that the configuration does not change – Clément BERTILLONsession.save_path
is overriden neither in Symfony configuration nor in any bundle. This should therefore default to%kernel.cache.dir%/sessions
but it is not what occurs, they are stored in the tmp folder. phpsession.save_path
value is set to/srv/www/my_domain/var/tmp
and it's the location where session files are written. – Wanjee