Skip to content
This repository has been archived by the owner on Apr 14, 2021. It is now read-only.

Session expires after 1 hour (by default) #15

Merged
merged 1 commit into from
Feb 27, 2018
Merged

Conversation

xoen
Copy link
Contributor

@xoen xoen commented Feb 27, 2018

Can be configured by setting the COOKIE_MAXAGE environment variable to
the number of seconds after which cookie session will expire.

@xoen xoen requested a review from axemonkey February 27, 2018 14:51
app/config.js Outdated
@@ -20,6 +20,10 @@ config.session = {
resave: true,
saveUninitialized: true,
secret: process.env.COOKIE_SECRET || 'shh-its-a-secret',
cookie: {
// In milliseconds. Defaults to 8 hours
maxAge: (Number.parseInt(process.env.COOKIE_MAXAGE, 10) || 28800) * 1000,

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think if process.env.COOKIE_MAXAGE is undefined, this will error rather than defaulting as parseInt() will choke.

Instead maybe do something like cookieSeconds: process.env.COOKIE_MAXAGE || 28800 and then multiply * 1000 after.

I think.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually, maybe not.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nope. Ignore. All is well.

:disappear:

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No worries. I tested from the console, etc... and it seems like Number.parseInt() is coping well with whatever you throw at it (as in it would return NaN when it can't convert the thing to an integer).

As NaN is falsey (assuming that is a word) it would then fall back to || 28800, etc...

No worries. Thanks for having a look Clive :)

@xoen xoen force-pushed the ag--cookie-max-age branch 2 times, most recently from 4959df9 to 27ef62b Compare February 27, 2018 16:46
@xoen
Copy link
Contributor Author

xoen commented Feb 27, 2018

@axemonkey FYI: As per discussion with @andyhd earlier I've reduced the expiration time to 1 hour.

Merging this.

Can be configured by setting the `COOKIE_MAXAGE` environment variable to
the number of seconds after which cookie session will expire.
@xoen xoen merged commit 1884f1e into master Feb 27, 2018
@xoen xoen deleted the ag--cookie-max-age branch February 27, 2018 16:51
@xoen xoen changed the title Session expires after 8 hours (by default) Session expires after 1 hour (by default) Feb 27, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants