express-session 是否不适用于 express 4.13?

Is express-session not working with express 4.13?

所以我根据 documentation for express-session, as far as I can tell. But my cookie is not getting created! According to the documentation, all you have to do is set the request.session value and the cookie should automatically be set. I'm not sure what voodoo enables this, but the magic seems to be broken. Just to be sure I verified against the example given here 设置了会话。我错了吗?这些是否缺少一些关键信息?

   //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);
            }
        });

所以我想知道我做错了什么,还是最新的有错误?我可以检查我的数据库,我确实在会话 table 的行上看到了正确的会话变量!

//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 日的最新信息。

使用下面的代码让会话在 EXPRESS JS V 4 中正常工作:-

    var express = require('express');
    var session = require("express-session");
    var cookieParser = require('cookie-parser');
    var app = express();
    app.use(cookieParser());
    var MemoryStore =session.MemoryStore;
    app.use(session({
        name : 'app.sid',
        secret: "1234567890QWERTY",
        resave: true,
        store: new MemoryStore(),
        saveUninitialized: true
}));

必须保存会话。

req.session.save(function(err) {
  // session saved
})

有关 express-session page 的更多详细信息。