Shanky
Shanky

Reputation: 15

windows phone 8.1 universal app : clear cookies

I am developing windows phone 8.1 universal app and i wish to clear cookies from browsers.

I have used windows.phone.controls namespace and used following code await new WebBrowser().ClearCookiesAsync(); but it says that it throws several error. Please help windows programmers .

I think the above code works well for silverlight app but not for universal app windows phone8.1 app. Please Help

Upvotes: 1

Views: 838

Answers (1)

Bret Bentzinger
Bret Bentzinger

Reputation: 376

The following should work for clearing the cookies for a specific URI:

Windows.Web.Http.Filters.HttpBaseProtocolFilter myFilter = new Windows.Web.Http.Filters.HttpBaseProtocolFilter(); 
var cookieManager = myFilter.CookieManager; 
HttpCookieCollection myCookieJar = cookieManager.GetCookies(new Uri("target URI for WebView")); 
foreach (HttpCookie cookie in myCookieJar) 
{ 
    cookieManager.DeleteCookie(cookie); 
}

Upvotes: 2

Related Questions