I'm using redis as a session store,
Storing sessions like so
[NameSpace]:[UniqueId] -> [email_id]
Here is the problem,
when a user resets their password, how do I invalidate all the sessions of that user ?
Here are the solutions I came up with,
Store email id as part of UID
Store sessions like so
[NameSpace]:[UniqueId]-[email_id] -> [email_id]
Then I can use SCAN MATCH
to delete all the keys when the user resets the password.
Maintain a list of UIDs
After storing sessions like
[NameSpace]:[UniqueId] -> [email_id]
Maintain a separate list with
[NameSpace2]:[email_id] -> [ "[UniqueId]", "[UniqueId]" ]
and invalidate the sessions using the list. (I can use redis
namespace pubsub to maintain the validity of the above list)
My Questions are
- What is the recommended way to do bulk session invalidation in redis ?
- Are there any security issues with storing the session-id like
[UniqueId]-[email_id]
in the cookie ?
PS: I'm aware that there is a similar question but I felt that it was noisy and geared towards express.js instead of being generic for redis and user-sessions. (Invalidating all of a single user's sessions in express.js)