-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
Add HTTP::Cookie#expire
#14819
Add HTTP::Cookie#expire
#14819
Conversation
Since the intent is to expire the cookie, then I'd also put an expiration date far further than 5 minutes ago (clocks can get unsynced) and use a fixed date, like the UNIX timestamp (1970-01-01 00:00:00 UTC). |
@ysbaddaden Hey julian! This little function is a convenience for destroying cookies (which usually means setting their expiry to some date in the past and setting their value to blank) I just thought others might want a convenient function to destroy cookies. Although as you pointed out, it is superflous. I just PR'd it to promote developer happiness :3 |
It would be much appreciated to follow the guidelines for feature discussions and open an issue for a new proposal first, to keep the general discussion independent of a PR with a concrete implementation. |
Actually, setting So I think the functionality should be implemented as |
Sorry about the typo. I can't run the test suite locally so I'm relying on the CI. |
HTTP::Cookie#destroy
IMO the name |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think that #expire or #expire! would reflect better the behavior.
There was a issue in the past for rails where the behavior of #delete for cookies was discussed. An outcome of that discussion was that can be applied here is that HTTP::Cookies type is not only used for browsers. For example #destroy in the context of a MITM proxy would have a different expectation. So I think #expire or #expire! would be better and more application agnostic.
I initially proposed |
Reasoning
I tried to use
cookies.delete("...")
today and it didn't cause the cookie to expire from the browser. It sent it again on the next request.This method sets the cookie value to an empty string and seets the expiry date to 5 minutes ago. Browsers automatically delete expired cookies.
My aim is to provide a convenience to anyone who happens to need to use
HTTP::Cookie