-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
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
fix middleware/session update cookie. #1960
Conversation
Thanks for opening this pull request! 🎉 Please check out our contributing guidelines. If you need help or want to chat with us, join us on Discord https://gofiber.io/discord |
should we refresh the expire time every time ? if you remove the fresh switch in the condition why is s.fresh still needed(think we are destroying the reason for introducing the property) ? would have expected some unittests outlining the problem or showing that your fix works -> otherwise it is not guaranteed that it is fixed forever |
Yes. Let's say session created at 2:00PM and expire time is set to 2 hours, each time you request a web page, the session expiration time is updated to stay 2 hours. If you request a page at 2:30PM, session expire time will be (correctly) updated to 4:30PM, but cookie still has expiration time at 4PM. In this case when request at any time after 4PM, the web session is invalid because session ID stored in client cookie expired and server regenerates one. I checked other session implementations like Gin's session middleware, they all update cookie expiration time. Sample code (Please click the
|
Ok, thanks |
Is it ok to merge this PR now? @ReneWerner87 |
Congrats on merging your first pull request! 🎉 We here at Fiber are proud of you! If you need help or want to chat with us, join us on Discord https://gofiber.io/discord |
Session middleware should always update client cookie so that cookie expires at the same time as session.