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

Explicitly calling save on a session can result in wrong expiry date #54

Closed
kheyse-autodesk opened this issue Nov 8, 2017 · 1 comment

Comments

@kheyse-autodesk
Copy link

kheyse-autodesk commented Nov 8, 2017

Due to the implementation of the PGStore.touch method, the expiry date in sess.cookie may be out of sync with the value in the expire column in the PG database. This is typically not a problem since only this expire column is used to filter expired sessions.
However, when explicitly calling sess.save(), the expiry date stored in sess.cookie is put into the expire column in the database (https://github.com/voxpelli/node-connect-pg-simple/blob/master/index.js#L214). Because the expiry date in sess.cookie may be a lot older than the actual expiry date stored in the expire database column, this is a problem.

When you don't call the sess.save() function explicitly, you don't notice this problem. Express-session will automatically call sess.touch() before calling sess.save() https://github.com/expressjs/session/blob/master/index.js#L237.
A workaround for me is to explicitly call sess.touch() before sess.save().

@voxpelli
Copy link
Owner

Not sure I follow – both .save() and .touch() updates the expiry time in the database and both derives the value from the session cookie? Can you explain a bit more?

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