Home » Php » php – Symfony – User logged in but session variables empty after some hours away

php – Symfony – User logged in but session variables empty after some hours away

Posted by: admin February 25, 2020 Leave a comment

Questions:

I have a Symfony 4.4 project, with registered users (using Guard). When the users log in, they’re redirected to an url to select a value that is stored in the session (something like the id of his office). I mean: a page is shown with a list of all the available offices, and when the user click on one, a session variable officeId is stored.

This works correctly, but this morning I’ve found a problem: if the user is logged in with the “remember me” option, when he uses the application after 6-8h away, he doesn’t need to log in again, but the officeId session variable doesn’t exist.

Is there any way to avoid this problem? Or I should create a filter to redirect the user if any session variable isn’t set?

How to&Answers: