因此,据我所知,我已经根据快速会话的文档设置了会话。但是我的cookie没有被创建!根据文档,您所要做的就是设置 request.session 值,并且应该自动设置 cookie。我不确定是什么伏都教能做到这一点,但魔法似乎被打破了。只是为了确保我根据此处给出的示例进行了验证。我错了吗?这些是否缺少一些关键信息?
//login route handler
app.post('/users/login/', function (req, res) {
//... get the row from DB, check the pass then set session
this.bcrypt.compare(password, row.hashed, function(err, passwordsMatch) {
if( passwordsMatch === true)
{
//set the session variable 'user'
req.session.user = row;
res.send(row);
}
});
所以我想知道我做错了什么,还是最新的错误?我可以检查我的数据库,并且确实在会话表中的行上看到了正确的会话变量!
//Here's my "configuration" of express-session.
app.use(function (req, res, next) {
res.header('Access-Control-Allow-Credentials', 'true');
next();
});
var storeOptions = {
//my database options (this works, it makes rows in db table)
};
var sessionStore = new SessionStore( storeOptions );
app.use(session({
name:'yay_session',
secret: 'some secret this is now',
resave: true,
saveUninitialized: false,
cookie: { maxAge: 600000,httpOnly: false, domain:'localhost' },
store: sessionStore
}));
为什么我的客户端 cookie 没有设置?它不会显示在资源调试面板中。所以我想知道最新的 4.13.3 版本与 express-session 1.11.3 协同工作是否存在错误。这是截至 8 月 27 日的最新数据。