最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

使用Nodej进行身份验证期间的不同数量会话

运维笔记admin20浏览0评论

使用Nodej进行身份验证期间的不同数量会话

使用Nodej进行身份验证期间的不同数量会话

我读这篇文章on Medium我来到了它写的会议数量link on Pastbin

在这篇文章中写道,经过多次调用这个命令“client $ curl -X GET http://localhost:3000 -b cookie-file.txt”,我必须得到一个相同的结果。但在输出中我有

Inside the session middleware
de5b7edc-09e7-47dc-b9f8-8ac0179ec1ea
Inside the homepage callback function
f559ee33-2928-41a0-94aa-39025578cbc6
Inside the session middleware
de5b7edc-09e7-47dc-b9f8-8ac0179ec1ea
Inside the homepage callback function
fcc48f22-2000-44f5-8f19-13adb1bf8191
Inside the session middleware
de5b7edc-09e7-47dc-b9f8-8ac0179ec1ea
Inside the homepage callback function
dc696106-10ea-413a-b60e-b1e725820311

我不明白为什么我会得到不同的号码会话。

回答如下:

试试这个:

    app.use((req, res, next) => {    
        req.session.init = "initProgram";  //this is very important for sessions, we need to initialize it for authentication.
        next();
    });

每次调用路由时,都会创建一个新会话。当您调用http://localhost:3000时,初始化会话,然后在后续调用中使用cookie仅使用该会话。

发布评论

评论列表(0)

  1. 暂无评论