req.session返回未定义

时间:2019-08-26 14:10:14

标签: mysql node.js ajax session

我已经尝试了很多方法,但是在登录会话时仍然无法定义

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);
}

在我的日志中,我得到了第一个会话,但我设置了会话,但下一个却未定义

0 个答案:

没有答案