Issue
I am trying to remove all the cookies from some domain, is there a way to do this?
The only method i saw is removeAllCookies.
Thank you.
Solution
As per documentation, we don't have a method for removing individual cookies.
But we could use an interesting work around with setCookie() to clear a site's cookies. as,
public abstract void setCookie (String url, String value)
Sets a cookie for the given URL. Any existing cookie with the same host, path and name will be replaced with the new cookie. The cookie being set will be ignored if it is expired.
So, the solution is, As mentioned in this answer, we need to manually clean up each cookie for each host key. eg:- facebook
android.webkit.CookieManager.getInstance().setCookie(".facebook.com", "locale=");
android.webkit.CookieManager.getInstance().setCookie(".facebook.com", "datr=");
android.webkit.CookieManager.getInstance().setCookie(".facebook.com", "s=");
android.webkit.CookieManager.getInstance().setCookie(".facebook.com", "csm=");
android.webkit.CookieManager.getInstance().setCookie(".facebook.com", "fr=");
android.webkit.CookieManager.getInstance().setCookie(".facebook.com", "lu=");
android.webkit.CookieManager.getInstance().setCookie(".facebook.com", "c_user=");
android.webkit.CookieManager.getInstance().setCookie(".facebook.com", "xs=");
Answered By - Let'sRefactor
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.