-
Notifications
You must be signed in to change notification settings - Fork 20
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
[Question] How to remove cookies? #14
Comments
Hey :) Yep, a dummy cookie is ok. I see your point, but |
Hey :) Thanks for the quick response. EDIT: Thought |
Right. I don't see an obvious way to fix this. And also I don't remember ever needing As for removing cookies by name, it certainly feels more intuitive, thank you for the suggestion. Could you review the changes before I merge it: 56a1fc3 |
Hmm... I don't think it's a correct approach though as cookie::CookieJar::remove says:
So I guess we should first check if the cookie is there and use its path and domain while removing it just by name. |
I think it's done: #15 @davidpdrsn @programatik29 would one of you guys have a few minutes to review it? It makes it possible to remove cookies by name, thakns 🙏 |
Oh you work quick. Also, i remove some cookies in my error handler, but i don't know how to use the Thanks:) |
What specifically do you mean by "error handler"? Do you mean using |
Or in case of a middleware, where you have only a request you can use
|
It's a |
Jar is kept in request extensions, so no access to request - no cookies :) |
make sense:) |
If you have request where you raise the error, you can process cookies there: enum Error {
LogOut
}
impl Error {
log_out(req: RequestParts) -> Self {
let cookies = Cookies::from_request(req).await?;
...
Self::LogOut
}
} If you don't have the request, you can put something into the response extensions. And then in a middleware you can check the extensions and change cookies. Maybe there's a simpler way of doing this, you can ask in the axum discord: https://discord.com/channels/500028886025895936/870760546109116496 |
So I guess we stick with the current behavior :) |
I am having some problem figuring out how to remove cookies.
Cause you need to have the cookie in order to remove it, which to me is weird as i would expect to remove it by it's name.
But if you get the cookie beforehand you can't use that cookie to remove it cause of lifetime issues.
Are you supposed to just create a dummy cookie like in the Counter example?
The text was updated successfully, but these errors were encountered: