Node/Express: Session Expire Event?

元气小坏坏 提交于 2020-01-04 04:11:19

问题


On asp.net, we have a session expire event. I'm using node.js with express.js and the default memory store for sessions. Every time I restart node, the sessions are lost. Ideally, I'd like to save the sessions to the db (can't use redis).

Is there a session expire event?


回答1:


If you want to save the sessions to a database which isn't Redis, there are more solutions: https://github.com/senchalabs/connect/wiki (check the Session Stores section).

As far as I know there isn't such an event for cookie/session expiration (I've looked at the code for Connect and didn't find such a feature).

Also if you don't want to use sessions with a database at all, the are several modules for that (storing sessions in cookies, encrypted):

https://github.com/jpallen/connect-cookie-session
https://github.com/ciaranj/express-session-cookie



来源:https://stackoverflow.com/questions/8539482/node-express-session-expire-event

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!