我在一个基于express的node.js项目中使用redis作为会话存储。会话通常工作得很好,但是当我重新启动应用服务器时,我发现我的所有会话都丢失了(即:所有用户被重定向到主页)。
我可以看到,通过使用redis管理工具,仍然可以在redis中访问会话密钥。
有什么想法吗?
我的服务器设置如下所示...
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()); });发布于 2014-01-27 07:35:35
由@robertklep回答
问题是由于sessionSecret在每次重新启动时都会发生变化而导致的。
https://stackoverflow.com/questions/21363504
复制相似问题