koa-redis icon indicating copy to clipboard operation
koa-redis copied to clipboard

Prevent invalid sessions on restart of application

Open crunchtime-ali opened this issue 8 years ago • 5 comments

I am using koa-generic-session with koa-redis. Everytime I restart my application all my sessions are invalid. I use it together with Passport and need to login again. How can I prevent this?

I setup the store with only basic configuration items:

const redisStore = require('koa-redis')
let store = redisStore({
      host: 'localhost',
      port: 6379
 })

crunchtime-ali avatar May 22 '17 18:05 crunchtime-ali

You can use session.client to directly access the Redis library functions and clear the table.

DaAwesomeP avatar May 22 '17 23:05 DaAwesomeP

How will that help me keeping the data after a restart? I want my sessions to remain valid.

crunchtime-ali avatar May 23 '17 00:05 crunchtime-ali

I'm sorry, I misunderstood. Are you explicitly setting keys?

DaAwesomeP avatar May 23 '17 01:05 DaAwesomeP

Yes, I do but right now I only set them like this: app.keys = ['keys', 'keykeys'];

crunchtime-ali avatar May 23 '17 01:05 crunchtime-ali

The only thing that I can think of is that the TTLs are running out or that Redis is clearing the DB after restart. Have you setup persistence in Redis?

DaAwesomeP avatar May 23 '17 01:05 DaAwesomeP