根据 connects documentation session 应该在浏览器关闭时过期:
By default
cookie.maxAge
isnull
, meaning no "expires" parameter is set so the cookie becomes a browser-session cookie. When the user closes the browser the cookie (and session) will be removed.
我正在使用带有 connect-mysql 的 express 3对于 session 存储(也尝试使用 connect-mongo,结果相同),这就是我设置 session 数据的方式。
req.session.userid = results[0].id;
req.session.ip = req.connection.remoteAddress;
req.session.useragent = req.headers['user-agent'];
req.session.is_logged_in = true;
这一切都很好,除了出于某种原因在 google chrome 浏览器中(这是在 OS X Lion 中。我现在无法在 win 或 linux 下进行测试)。
有人在 google chrome 中遇到过这个问题并且知道解决它的方法吗?
最佳答案
这是一个相当大胆的猜测,但如果是这样我也不会太惊讶。如果您安装了任何使用此功能的扩展程序,谷歌浏览器将继续在后台运行。如果在注销 session 后出现这种情况,则应重置 session 中的日志。
如果不是,请打开开发者工具 (cmd+alt+i
) 并从那里复制所有关于 cookie 的信息 (resources
-cookies
-yourdomain.com
)。 (特别是Expires
一栏写的,因为应该是Session
)
关于javascript - 谷歌浏览器 session 过期= null 不工作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10957800/