Hello,
MAUI that targets Windows platform uses WinUI3, you can try getting the native platform view (WebView2
) with WebViewHandler
on Windows, then clean cookie by CoreWebView2CookieManager.DeleteAllCookies Method. Please refer to the following code:
XML
<StackLayout>
<Button Text="ClearCookie" Clicked="Button_Clicked"></Button>
<WebView x:Name="MyWebview" Source="XXXX" HeightRequest="400" WidthRequest="400" ></WebView>
</StackLayout>
Clicking button to clean cookies.
private void Button_Clicked(object sender, EventArgs e)
{
#if WINDOWS
var platformView = MyWebview.Handler.PlatformView as WebView2;
platformView.CoreWebView2.CookieManager.DeleteAllCookies();
#endif
}
Best Regards,
Wenyan Zhang
If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.