具有RedisStore会话超时的Node.JS [英] Node.JS with RedisStore session timeout

查看:192
本文介绍了具有RedisStore会话超时的Node.JS的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用Redis将会话存储在我的node.js应用程序中,托管在heroku上,但redis正在保存会话存储,我如何让它们自动过期?

i'm using Redis to store sessions in my node.js app, hosted on heroku, but redis is keeping the session stored, how can i make them expire automatically?

我的快递应用程序是这样配置的:

My express app is configured this way:

var app = express.createServer(
  express.static(__dirname + '/public', { maxAge: 31557600000 }),
  express.cookieParser(),

    express.session({ secret: 'secret', store: new RedisStore({
          host: 'myredishost',
          port: 'port',
          pass: 'myredispass',
          db: 'dbname'
      })})
);


推荐答案

在连接会话中间件文档状态中,您需要设置cookie对象的maxAge属性:

As the Connect session middleware docs state, you need to set the maxAge property on the cookie object:

express.session({ secret: 'secret', store: ..., cookie: { maxAge: 60000 }});

阅读更多关于此处的信息: http://senchalabs.github.com/connect/middleware-session.html

Read more about that here: http://senchalabs.github.com/connect/middleware-session.html

这篇关于具有RedisStore会话超时的Node.JS的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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