我希望有一个“留在登录”选项,如Gmail提供的选项。这样,用户就可以决定在先前关闭一个新的浏览器会话后,他们是否希望在打开该会话时保持该会话的打开状态。
查看github的问题时,我看到了the cookie-session component doesn't provide a way to upate the maxAge
property dynamilly。
那么,我想知道是否有任何方法可以通过cookie-session
组件实现“保持登录”功能。
对我来说,这似乎是一个正在下载80K times a month的组件的基本功能。
发布于 2016-01-20 04:26:59
// This allows you to set req.session.maxAge to let certain sessions
// have a different value than the default.
app.use(function (req, res, next) {
// here you can see whether they checked the checkbox or not, and change maxAge.
// the default should be that it expires when the browser is closed
req.sessionOptions.maxAge = req.session.maxAge || req.sessionOptions.maxAge
// or you can try to set expires to 1 day from now:
req.sessionOptions.expires = new Date(Date.now()+86400000)
// or at the end of the session:
req.sessionOptions.expires = 0
})
https://stackoverflow.com/questions/34656168
复制相似问题