Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

session expires maxAge #231

Open
jinceon opened this issue Apr 20, 2016 · 0 comments
Open

session expires maxAge #231

jinceon opened this issue Apr 20, 2016 · 0 comments

Comments

@jinceon
Copy link

jinceon commented Apr 20, 2016

我的session配置了maxAge=60000,60秒。

app.use(session({
    name:'jsessionids',
    store: new redisStore({
        host:config.redis.host,
        port:config.redis.port,
        pass : config.redis.password,
        db: config.redis.database
    }),
    cookie: {maxAge: 60000}, //milli
    resave: false, // don't save session if unmodified
    saveUninitialized: false, // don't create session until something stored
    secret: 'yueai_muzhi'
}));

但是我发现,
node_modules/connect-redis/lib/connect-redis.js里,getTTL方法会把我的时间改为1天。

function getTTL(store, sess) {
  debug('getTTL', store, session.cookie);   //我在这打印了日志
  var maxAge = sess.cookie.maxAge;
  return store.ttl || (typeof maxAge === 'number'
    ? Math.floor(maxAge / 1000)
    : oneDay);
}

打印出来的结果是

connect:redis getTTL +28ms undefined { originalMaxAge: 60000,
  expires: '2016-04-20T02:36:42.376Z',
  httpOnly: true,
  path: '/' }

cookie里没有maxAge,有的是originalMaxAge
请问你们是怎样处理session的?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant