节点/表达:会话过期事件? [英] Node/Express: Session Expire Event?

查看:43
本文介绍了节点/表达:会话过期事件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在asp.net上,我们有一个会话过期事件.我正在将node.js与express.js和默认的内存存储区用于会话.每次重新启动节点时,会话都会丢失.理想情况下,我想将会话保存到数据库(不能使用redis).

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).

是否有会话过期事件?

推荐答案

如果要将会话保存到不是Redis的数据库中,则有更多解决方案:

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).

据我所知,没有这样的Cookie/会话过期事件(我看过Connect的代码,却没有找到这样的功能).

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).

如果您根本不想使用数据库会话,则可以使用以下几个模块(将会话存储在cookie中,进行加密):

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

这篇关于节点/表达:会话过期事件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆