-
-
Notifications
You must be signed in to change notification settings - Fork 4.8k
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
extendSessionOnUse not working as expected #8981
Comments
Thanks for opening this issue!
|
Last time I tried to use this I came to the same conclusion (IIRC). I think not updating the session expiration on every use is actually a good design decision, as it would hit the Mongo with session object write with every authenticated read. But it may be wise to perhaps make this configurable or invent some better update magic. For example, if the session expiration is set to N days, it would be wise to extend the use every day. If the session expiration is set to N minutes, it may be wise to extend every minute. if session expires in N hours (but less then a day), it may be wise to update every hour. so hardcoding 24 hours probably makes sense for longer session expirations in days, and does not work at all for sessions with expirations in hours or minutes. |
Please feel free to open a PR; likely a simple fix, just remove the |
This is still open to work on right. Can I work on this? |
@vivekjoshi556 Please do work on this, I will beta test for you. I have a good idea above how to fix it without incurring additional writes on Mongo, but I will not have a time to look at it in the near future! |
@vivekjoshi556 Sure, please go ahead. |
🎉 This change has been released in version 7.1.0-alpha.9 |
🎉 This change has been released in version 7.1.0-beta.1 |
🎉 This change has been released in version 7.1.0 |
New Issue Checklist
Issue Description
Issue with 'extendSessionOnUse'
I don't understand how this feature works.
So this is where the magic happens and the session gets extended.
But looking at this piece of code it takes lastUpdated and yesterday and if lastUpdated is greater than yesterday it returns.
So if I've doing 60 minute sessions, well this will never actually extend the session. So for this to work a session needs to be at least 24 hours.
This isn't documented anywhere and it's counterintuitive.
Am I missing something.
Steps to reproduce
Enable extendSessionOnUse.
Set session to 60 minutes.
Perform actions for authenticated user and look at session expiry. it doesn't update.
Now set session to 48 hours.
Perform actions and notice that session expiry does update.
Actual Outcome
I expect Session expiry to update for any session duration.
Expected Outcome
I expect Session expiry to update for any session duration.
Environment
NodeJS 21
Server
Ubuntu 22
local
Database
6.0
local
Client
REST
REST
Logs
N/A
The text was updated successfully, but these errors were encountered: