我已经尝试了很多方法,但是在登录会话时仍然无法定义
Get "undefined" for req.session in nodejs Session in nodejs
app.use(session({
secret: 'mYsEcReTkEy',
resave: true,
saveUninitialized: true,
cookie: { secure: false }
}));
app.use('/users/data' , getUserData);
app.get('/order/new' , addOrderPage)
addOrderPage: (req, res) => {
console.log('ll', req.session.userData);},
getUserData: (req, res) => {
let userData = req.query.userData;
req.session.userData = userData;
console.log('ll55', req.session.userData);
}
在我的日志中,我得到了第一个会话,但我设置了会话,但下一个却未定义