所以我根據documentation設置了會話進行快速會話,據我所知。但我的cookie沒有被創建!根據文檔,你所要做的就是設置request.session值,並且cookie應該自動設置。我不確定巫術能做到這一點,但魔法似乎被打破了。只是爲了確保我對照給出的例子here進行了驗證。我錯了嗎?這些是否缺少一些關鍵信息?快遞會話是否與快遞4.13不一致?
//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版本是否與快速會話1.11.3一起工作。這是最新的27月使用
這個問題浪費了我近一天的時間。我非常感謝你。 –
這是非常無益的。 – Phil