我了解到您可以在启动应用程序时设置 maxAge 如下:
connect.session({ secret: 'keyboard cat', cookie: { maxAge: 60000 }})
但是,我想按照“记住我”设置的方式实现一些东西,我该怎么做呢?
非常感谢:)
杰森
最佳答案
您可以在属于当前用户的单个 cookie 上设置 expires
或 maxAge
:
// This user should log in again after restarting the browser
req.session.cookie.expires = false;
// This user won't have to log in for a year
req.session.cookie.maxAge = 365 * 24 * 60 * 60 * 1000;
关于node.js - 如何在 express 中设置单个 session maxAge?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9714785/