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

How to change the maxage of a session for a specific user? #15

Closed
azeemba opened this issue May 24, 2014 · 6 comments
Closed

How to change the maxage of a session for a specific user? #15

azeemba opened this issue May 24, 2014 · 6 comments
Assignees
Labels

Comments

@azeemba
Copy link

azeemba commented May 24, 2014

In express3.x this was possible using req.session.cookie.maxAge.
However it seems that req.session.cookie is undefined. So is it possible to change the properties of the cookie without changing them globally?

@azeemba
Copy link
Author

azeemba commented May 24, 2014

Duplicate #5

@azeemba azeemba closed this as completed May 24, 2014
@azeemba azeemba reopened this May 24, 2014
@azeemba
Copy link
Author

azeemba commented May 24, 2014

Nevermind that doesn't solve issue about changing it for specific cookies.

@ghost
Copy link

ghost commented Oct 15, 2014

I added a simple function which allows you to change session options. The code is here: 6038e56

Usage example in the pull request: #25

You can use this to update any of the options described in the cookie-session ReadMe. I'm not sure if it breaks anything. It works for me, but use at your own risk.

@dougwilson dougwilson self-assigned this Jul 2, 2015
@dougwilson
Copy link
Contributor

Hi! Sorry this module has been sitting around for so long! I have added how you can do this with req.sessionOptions.maxAge in the readme, which has been available for the lifetime of this module, but just undocumented.

@dougwilson
Copy link
Contributor

Eh, nevermind. That doesn't work right. This module needs a serious overhaul :)

@dougwilson
Copy link
Contributor

For now, with version 1.2.0, the solution would be as follows if you want a sticky maxAge:

app.use(cookieSession())
app.use(function (req, res, next) {
  req.sessionOptions.maxAge = req.session.maxAge || req.sessionOptions.maxAge
})

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

Successfully merging a pull request may close this issue.

2 participants