-
-
Notifications
You must be signed in to change notification settings - Fork 2.1k
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
Method to delete a specific set of cookies #4942
Comments
Hi @Lonami there is |
I don't recall if I saw it, but that seems to delete all the cookies of the session. I was looking for something that deletes only some of the cookies. I'd expect a method where I can provide a list of cookies to delete. |
I have updated the original post and title to clarify. |
This makes sense now. @webknjaz can I start working on it? |
Someone is working on the issue? cc @webknjaz |
@WolframAlph @myusko feel free to implement this. |
CookieJar is for client cookies. |
I am using a single |
Okay, I can imagine the I unlikely can find time for the feature soon but open to review/merge a PR if somebody wants to propose it. |
What about a session.cookie_jar.clear(filter=lambda cookie: cookie.domain == 'example.com') |
My guts feel that Maybe I'm wrong and good documentation with a couple of examples: one for a site with subdomains and another for something else -- can teach users comprehensively. |
I was thinking something along the lines of: def clear(self,
domain: Optional[str]=None,
filter: Optional[Callable[[SimpleCookie], bool]]=None) -> None:
"""
Clears the cookies from this jar.
If the ``domain`` parameter is specified, only the cookies belonging
to that specific domain will be cleared.
If the ``filter`` parameter is specified, only those cookies for which
the filter returns `True` will be cleared. If any of the calls to the
filter fail, no changes will be made to the jar.
A `ValueError` is raised if both ``domain`` and ``filter`` are
specified at the same time.
""" People don't need to use |
The design is viable.
|
We could technically make both parameters work, but because I realized it would probably be more confusing (is it clearing both domain and filter, or filtering only those in domain?), I edited my comment to mention that they are exclusive in the documentation. If you're happy with the proposed function signature I can go with that. |
Please use separate methods with the following signatures:
|
Are you sure? The jar maps |
I don't think that the method is a performance bottleneck. For |
Currently if one wants to delete some cookies, the way to do it is not really obvious:
It would be nice to have a method to do this cleanly.
Use case: one may want to clear the cookies from a session before trying again the same operation but not wishing to recreate the session (or being unable to do so).
The text was updated successfully, but these errors were encountered: