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

[Problem/Bug]: DeleteCookie / DeleteCookies / DeleteCookiesWithDomainAndPath won't delete partitioned cookies #4669

Open
mgalla10 opened this issue Jul 8, 2024 · 3 comments
Assignees
Labels
bug Something isn't working

Comments

@mgalla10
Copy link

mgalla10 commented Jul 8, 2024

What happened?

Third-party websites may add cookies that are partitioned, as part of Chromium's CHIPS pattern. I've attempted to remove these cookies via the CoreWebView2CookieManager's DeleteCookie, DeleteCookies, and DeleteCookiesWithDomainAndPath APIs, but none of these will remove them. Only DeleteAllCookies successfully removes partitioned cookies, at the cost of also removing other cookies we'd prefer to keep.

Importance

Moderate. My app's user experience is affected, but still usable.

Runtime Channel

Stable release (WebView2 Runtime)

Runtime Version

126.0.2592.87

SDK Version

1.0.2535.41

Framework

Winforms

Operating System

Windows 11

OS Version

10.0.22631

Repro steps

Navigate to any website hosted by a WebView2 Winforms app. Open DevTools and enter the following commands in the console to add a normal and persistent cookie:

  • cookieStore.set({ name: "Normal-Cookie", value: "normal-value", secure: true, path: "/", sameSite: "none" })
  • cookieStore.set({ name: "Partitioned-Cookie", value: "partitioned-value", secure: true, path: "/", sameSite: "none", partitioned: true })

Still in DevTools, go to the Application tab, find your website's domain under the Cookies section, and note the cookie(s) you added.

In your WebView2 logic, obtain the cookie via the CoreWebView2CookieManager's GetCookiesAsync API, then attempt to remove it by using either the DeleteCookie, DeleteCookies, or DeleteCookiesWithDomainAndPath APIs.

Back in DevTools, refresh the cookies for your website. Notice that the while the normal cookie was removed, the partitioned cookie was not.

If you run the same workflow but clear the cookies using DeleteAllCookies, both the normal and partitioned cookies will be gone.

Repros in Edge Browser

No, issue does not reproduce in the corresponding Edge version

Regression

Don't know

Last working version (if regression)

No response

@mgalla10 mgalla10 added the bug Something isn't working label Jul 8, 2024
@leonidukg
Copy link

See #4154 (comment)

@mgalla10
Copy link
Author

@leonidukg Thank you! Using CDP to remove the cookie storage data for the partitioned cookie's domain works as a workaround.

@mgalla10
Copy link
Author

mgalla10 commented Jan 3, 2025

Is there any update on this? We're starting to encounter issues even with the abovementioned workaround. We have a workflow where we'll delete all cookies then later conditionally re-add them. Thanks to the workaround we're successfully able to delete the cookies, but because the CoreWebView2Cookie class doesn't have any sort of Partitioned attribute, we're unable to re-add those partitioned cookies.

I recognize this isn't specifically about deleting partitioned cookies, but adding a CoreWebView2Cookie::Partitioned attribute would likely solve both the original issue and this new request.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants