koajs / koa-redis

Redis storage for Koa session middleware/cache with Sentinel and Cluster support
MIT License
352 stars 40 forks source link

Get opened sessions list #7

Closed azappa closed 7 years ago

azappa commented 9 years ago

I'm using koa-generic-session + koa-redis for my Koa app. I got an administration zone where admin can set user levels. When a user login his infos (I got them from a mongodb item) are stored into session (this.session.user). The problem is when admin change a user's level user still remain with previous read/write permission. How can I delete that user session from redis and force him to login when visit my app? Thanks!

DaAwesomeP commented 8 years ago

If you're setting TTLs, then you can simply use the client object to manually list all of the keys in Redis. You'll have to parse all of them and in doing that store all of the parsed data in memory as you do that though. The key:value system for the sessions is based on browser:user, not user:data.

DaAwesomeP commented 8 years ago

@azappa you could also record the value of the cookie and which user it is assigned to at each request in another DB.