koajs/koa-redis

Prevent invalid sessions on restart of application

crunchtime-ali opened this issue · 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
 })

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

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

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

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

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?