我想要一个“保持登录状态”选项,例如 Gmail 提供的选项。
这样,用户可以决定如果他们想在之前关闭浏览器会话后打开新的浏览器会话时保持会话打开。
查看我看到的 github 问题cookie-session 组件不提供更新的方法maxAge财产动态 https://github.com/expressjs/cookie-session/issues/21#issuecomment-52973886.
我想知道是否有任何方法可以实现“保持登录”功能cookie-session
成分。
在我看来,这似乎是正在下载的组件的基本功能每月 80K 次 https://www.npmjs.com/package/cookie-session.
// 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
})
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)