node.js - req.session 不在另一条路线上工作
问题描述
我试图在 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")
这将正确终止连接并写入会话
推荐阅读
- nexus3 - docker 上的 Nexus sonatype/nexus3:3.17.0 告诉它只使用一个 cpu
- php - Xdebug 在 PhpStorm Ubuntu 18 PHP 中不起作用
- c# - 如何在 Scrollviewer 上为子控件禁用自动滚动
- reactjs - 如何在 React styleguidist 中将道具传递给 Readme.md 文件中的组件?
- python - 如何在不更改特定列的情况下对数据框中的数据进行重新采样?
- angular - 获取 ExpressionChangedAfterItHasBeenCheckedError
- c# - 异步ajax调用和异步c#控制器方法
- database - Access 报告数据库“不一致”
- android - 在 Android AOSP 上启用基于 TCP/IP 的 adb 调试
- python - 如何解决 - 与 192.168.XX 的连接已关闭?