req.session 没有在另一条路线上工作

req.session is not working on another route

我正在尝试使用 express 中的会话,但它无法正常工作

app.get("/mod", async function (req, res) {
     var sess = req.session;
      console.log(sess)
})

输出为

Session {
cookie: { path: '/', _expires: null, originalMaxAge: null, httpOnly: true }, 
uid: '1234123123',
utag: 'Tag_etc',
uav: 'other stuff'
}

但是如果我使用

     app.get("/approve", async function (req, res) {
            var sess = req.session;
            console.log(sess)
})

输出是

Session {
    cookie: { path: '/', _expires: null, originalMaxAge: null, httpOnly: true }
}

没有我需要的其他东西。知道为什么会这样吗?

感谢您的帮助:D

尝试发送回复:res.send("hello") 这将正确终止连接并写入会话