nodejs使用connect-redis怎么设置session?如果直接app.use(require('express-session')({
resave:false, saveUninitialized: true, secret: 'lalala',
}));
app.get('/', function (req, res) { console.log('session: ', req.session);
});是可以得出session: Session { cookie:
{ path: '/', _expires: null, originalMaxAge: null, httpOnly: true } }如果用connect-redisvar session = require('express-session');var redisStore = require('connect-redis')(session);
app.use(session({
saveUninitialized: true,
resave: false,
secret: 'lalala',
store: new redisStore({ host: 'localhost', port: 6379}),
}));得到的是undefined,得不到session
添加回答
举报
0/150
提交
取消