Mayank Sugandhi
Mayank Sugandhi

Reputation: 397

how to Remove/Delete specific cookie programmatically in android?

I want to call web service , it needs to delete specific cookie before calling web service, i want code to remove or delete specific cookie in android.

I have Url which i want to delete cookie.

Upvotes: 3

Views: 4174

Answers (1)

devpro
devpro

Reputation: 16117

You can try CookieManager.setCookie() and set the cookie to the empty string like that:

String cookieVal = "yourCookie=''";
cookieManager.setCookie(cookieDomain, cookieVal);

You can also expire cookie like that:

String cookieVal = "yourCookie=;expires=Sun, 31 Dec 2015 00:00:00 UTC;";

Upvotes: 6

Related Questions