如何在请求之间的express中保存sessionID?

发布于 2025-02-01 00:15:50 字数 656 浏览 1 评论 0原文

我有一个应用程序,可以从客户端向服务器提出3个请求。

我需要使用我从ws获得的数据。

因此,我想将一些数据存储在服务器中,而不要将其返回到客户端。

如何设置我的sessionID在Express Server执行客户端请求中确实关联?

现在,我的sessionId重新启动了我对服务器的每个请求...

我使用reverseproxy使用pm2运行我的Express Server。

我的客户端和服务器在https上运行,

我的会话配置看起来像这样:

app.set("trust proxy", 1)
app.use(session({
     proxy:true,
     resave:true,
     secret: process.env.SECRET,
     cookie: {secure : true, maxAge : 8 * 60 * 60 *1000,sameSite: "none", httpOnly:false},
     credentials:true,
     saveUninitialized:true,

})
)

I'm have an app which i make 3 requests from the client to the server.

Each call i need to use data that i get from the WS .

So i want to store some data in the server and don't return it to the client.

How can set my sessionID do be associated in the express server do the client request?

Now my sessionID restart every request that i make to the server...

I use reverseProxy to run my express server using pm2 .

My client and my server run on HTTPS

My session config look like this :

app.set("trust proxy", 1)
app.use(session({
     proxy:true,
     resave:true,
     secret: process.env.SECRET,
     cookie: {secure : true, maxAge : 8 * 60 * 60 *1000,sameSite: "none", httpOnly:false},
     credentials:true,
     saveUninitialized:true,

})
)

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文