Skip to content
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] - Delete a certain cookie instead of clear all cookies #742

Open
PeterNgTr opened this issue Jan 29, 2020 · 6 comments
Open

[Feature] - Delete a certain cookie instead of clear all cookies #742

PeterNgTr opened this issue Jan 29, 2020 · 6 comments

Comments

@PeterNgTr
Copy link

@PeterNgTr PeterNgTr commented Jan 29, 2020

Based on the docs here https://github.com/microsoft/playwright/blob/master/docs/api.md#class-browsercontext we cannot delete a certain cookie, is there any consideration to have that kind of feature?

@pavelfeldman
Copy link
Contributor

@pavelfeldman pavelfeldman commented Jan 29, 2020

We could add that. The cookie would be identified by the secure+domain+path+name key. Could you share the use case for the individual cookie removal?

(You can work around it today via getting all cookies, deleting all cookies and restoring everything but one cookie in case your context is not huge)

@PeterNgTr
Copy link
Author

@PeterNgTr PeterNgTr commented Jan 30, 2020

@pavelfeldman I'm not really sure if there are many users want to manipulate the cookies but it would be nice to have an option to delete a special cookie key. Thanks!

@PavelBansky
Copy link

@PavelBansky PavelBansky commented Jan 30, 2020

@PeterNgTr : wrong Pavel

@PeterNgTr
Copy link
Author

@PeterNgTr PeterNgTr commented Jan 31, 2020

@PeterNgTr : wrong Pavel

hey man, sorry for the wrong mentioned.

@dgozman dgozman changed the title [Question] - Delete a certain cookie instead of clear all cookies [Feature] - Delete a certain cookie instead of clear all cookies Feb 27, 2020
@zakuru
Copy link

@zakuru zakuru commented Apr 6, 2020

Hi All, @PeterNgTr

I was thinking about this feature - should not we try do to something like delete all cookies matching a certain set of criteria.
What would be the point of limiting the scope to delete only one cookie ?
Would be something like

cookies.DeleteWhere((cookie) => cookie.domain = "xxx")
cookies.DeleteWhere((cookie) => cookie.domain = "xxx" && cookie.path == "zzz" )
@nrayburn-tech
Copy link

@nrayburn-tech nrayburn-tech commented Apr 24, 2020

@pavelfeldman, I was looking into adding this. I am not super familiar with how playwright interfaces with Chromium, so correct me if I am wrong anywhere.
Using docs from here, https://chromedevtools.github.io/devtools-protocol/tot/Storage/, there doesn't seem to be a method for Storage to delete an individual cookie. Page and Network have relevant methods to delete an individual cookie. I don't know if those are applicable though.
The other option would be like you mentioned, delete all cookies and restore the others. This could be created and exposed to the users as a method just for convenience and would internally still use clearCookies and add/setCookies.
Any thoughts?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
6 participants
You can’t perform that action at this time.