-
-
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
Feature: Session Only Cookies #1752
Feature: Session Only Cookies #1752
Conversation
… middleware function
…/sessionOnlyCookies
|
hmm with the feature i actually only meant the csrf middleware thought you could set the cookie to session without this switch by setting the expires to 0 but this does not work with the csrf middleware, because there the default is used we need the check there but a check to take the default value in case of doubt |
Wanted to update after your review.
Oh that is actually right.. So should I revert it from there?
Didn't get you.. do you want me to keep the |
Yeah, keep the config settings and do it in this way |
@ReneWerner87 I read about how cookies can be made session only, and I found that Expires and Max-Age have to be omitted. Setting Expires to 0 will make browser delete the cookie immediately, which you can read about here and here. So there is one observation:
For a cookie to be session only, we cannot just set expiration to 0 which means we have to keep a flag in What are your thoughts on this? I will proceed further once we decide what needs to be done. |
fiber/middleware/csrf/config.go Line 150 in ad1a925
The line I meant, for that we would need the setting We need to know that the user differs from the default |
@ReneWerner87 understood. I will use the setting to bypass setting expiration altogether. |
ok perfect only this task is missing |
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 |
Allows setting cookies that last for just the browser session by using
SessionOnly
property infiber.Cookie
which ignoresMax-Age
andExpires
headers if set to true.Now you can set a session only cookie like so:
This should close #1610.