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

Add maxAge to cookie options #2518

Closed
skid opened this issue Nov 8, 2023 · 1 comment
Closed

Add maxAge to cookie options #2518

skid opened this issue Nov 8, 2023 · 1 comment

Comments

@skid
Copy link
Contributor

skid commented Nov 8, 2023

Is your feature request related to a problem? Please describe.

The problem with the sessionDuration setting is that it looks at the session record in the database only and decides to kill the session based on the last access time. However, the session and session.sig cookies don't have a maxAge setting so they expire when the browser session expires, which is unpredictable. On desktops, it's usually when you close the browser, but on mobile it's whenever the OS decides (mostly). This leads to random logouts for users.

A simple way to fix this is to allow the maxAge setting in cookieOptions which will be passed to the cookie expressed middleware.

@michaelbromley
Copy link
Member

michaelbromley commented Nov 14, 2023

I'll add maxAge to the interface. For now, you should still actually be able to add it (although you'll need to make TypeScript happy) as the entire object gets passed as-is to the cookieSession middleware.

Note that currently, we do set maxAge when logging in with the rememberMe: true input set:

req.sessionOptions.maxAge = ms('1y');

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

2 participants