I have started a project with symfony 4.3.
The code for registering and authenticating users was generated using the console, with bin/console make:auth
and bin/console make:registration-form
, and I didn't really modify it beyond that.
Now, I have some page which are restricted to certain user roles. This is configured in config/packages/security.yaml, wih for exemple
security:
access_control:
- { path: ^/admin, roles: ROLE_ADMIN }
I also have a form that allows me to modify a user's role. Now this is the crux of the issue : if I modify the role of a user which is currently connected, the pages that he can access do not change until he logs out and logs in again. Since the database is properly updated, this means the his former role is still stored somewhere. I need to know where, so that I can update it without forcing him to log out and in again.
I don't think that it is in a plain file, as find . -mmin 5
find nothing after I create a new user and log in as them. I've seen var/cache//session mentioned, but I don't have this directory. I see nothing in the database either, nor any cookies with the information on my browser.
So, where does Symfony store information on logged in users ?
https://stackoverflow.com/a/57676864/11410707
This one solves (part of) my issue, but only if I modify the current user, not if I modify another. I'm also still interested in where tokens are stored.
The question has been locked even though the two links don't provide the answer, so here it is for the record :
The info on logged in users is stored in the PHP sessions of each user. In turn, the PHP sessions are stored as plain file in the directory /var/opt/remi/php73/lib/php/session/ (at least on my CentOS install).
Each session can only be accessed by the corresponding user, identified by the cookie PHPSESSID. Thus, it's not possible to refresh a remote user's session directly.