My php session with Symfony 4.0 expire too soon even if I set it up for several days in config/packages/framework.yaml
.
framework:
{...}
session:
handler_id: ~
cookie_lifetime: 604800
{...}
When the user complete the signin process, he can navigate on the website and, if he return after few minutes, he doesn't need to signin again.
But if he return after 1 or 2 hours (don't know precisely) the session is expired and he must sign in again.
One of the solution that seems worked, was to change what you see above in:
handler_id: session.handler.native_file
save_path: "%kernel.root_dir%/sessions"
cookie_lifetime: 604800
Unfortunately that solution solved the problem in the dev environment, but crashed the app once that I pulled the code on the server.
Problem solved.
The problem was save_path. Just use the parameters suggested in the official Symfony Documentation. In this way your cookies will be correctly stored.
session:
handler_id: session.handler.native_file
save_path: '%kernel.project_dir%/var/sessions/%kernel.environment%'
cookie_lifetime: 604800
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With