Reputation: 165
I'm using redis as the session store in an express based node.js project. The sessions work fine generally but when I restart the application server I find that all my sessions are lost (ie. all users are redirected to the homepage).
I can see the session keys are still accessible within redis by using the redis admin tools.
Any ideas?
My server setup looks like the following...
var redisSessionStore = require('connect-redis')(express);
global.sessionStore = new redisSessionStore({prefix:"sess:"});
app.configure(function(){
app.use(express.cookieParser());
app.use(express.session({ secret: sessionSecret, store: global.sessionStore, key: global.sessionCookieName, cookie: { secure: true, httpOnly: true, domain: "." + global.canonical, expires: false} }));
})
app.configure('development', function () { app.use(express.errorHandler({ dumpExceptions: true, showStack: true })); });
app.configure('production', function () { app.use(express.errorHandler()); });
Upvotes: 0
Views: 905
Reputation: 165
Answered by @robertklep
The problem was being caused by sessionSecret was changing on each restart.
Upvotes: 1