I store users sessions in DB, and as it was imposed by authentication library, that I have implemented, the userID is stored in session. So after log in there is only one DB query to check instead two for each page load.
Now I need to implement rolls(group), by default the library checks user roll on every request, but for my use case it's redundant. For the near future I don't expect the roll to change more than 1-2 time in user lifetime. So i decided to store in session as well.
The problem here is that user_1 (e.g Admin) will change rolls for user_2 (e.g Member). And untill the session is alive - there will be no changes for the user_2. I could not find any easy native PHP access to other session without starting a new session. But as I store the session in DB I can easily search for session with data I need and then alter it.
The question is how do I SELECT (find) entry in session data using Regex?
...user_id|s:1:"5";group|s:1:"3";email|s:13:"mail@mail.com";...
and change it to
;group|s:other_str_number:"any_other_group_number"
Or are there any other way?
Aucun commentaire:
Enregistrer un commentaire