Repository navigation
Extend session with "remember me" - #281
Merged
Merged
Conversation
Instead of just storing the username in client-side storage and populating it on the login page, keep the user logged in for up to 30 days if they select "remember me".
Member
Author
|
I just now tested this code with the following change applied so that I would not need to wait for 8 hours: diff --git a/serve.js b/serve.js
index b0df969..b9f1415 100644
--- a/serve.js
+++ b/serve.js
@@ -108,10 +108,10 @@ app.use(express.static(__dirname + '/public'));
app.use(bodyParser.urlencoded({ extended: true })); // Allows form submission
app.use(bodyParser.json()); // json parser
app.use(session({
- // Sessions expire every 8 hours
- cookie: { maxAge: 8 * 60 * 60 * 1000 },
- // Check for expired sessions once per hour
- store: new MemoryStore({ checkPeriod: 60 * 60 * 1000 }),
+ // Sessions expire every minute
+ cookie: { maxAge: 60 * 1000 },
+ // Check for expired sessions once per second
+ store: new MemoryStore({ checkPeriod: 1000 }),
resave: false,
saveUninitialized: false,
secret: crypto.randomBytes(64).toString('hex'),Without "remember me", my sessions expired after a minute; with "remember me", they were still valid after more than two minutes. I would like someone else to do some testing if possible before we merge this. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #246. Instead of just storing the username in client-side storage and populating it on the login page, keep the user logged in for up to 30 days if they select "remember me".
Please note that I have not yet tested this code.