Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android WebView remove cookies from specific domain

How to remove cookies from WebView on specific domain?

Like this method when I want to remove all cookies.

android.webkit.CookieManager.getInstance().removeAllCookie();

To be specific, I want to delete all .facebook.com cookies:

like image 922
Raphael Marco Avatar asked May 02 '14 02:05

Raphael Marco


People also ask

What is the use of cookiemanager in WebView?

Secondly CookieManager is used to store cookie for WebView. The key changes to solution is: use cookie.getDomain () instead of explicit domain. Show activity on this post.

What is the use of cookiesyncmanager in Android?

Firstly CookieSyncManager is deprecated on later version of android since api 21 according to doc. So decided not to use it anymore. Secondly CookieManager is used to store cookie for WebView. The key changes to solution is: use cookie.getDomain () instead of explicit domain. Show activity on this post. Show activity on this post.

Will clearcookies yahoocookies work on Android emulators?

After calling clearCookies yahooCookies will be null. This implementation feeds my needs, I have tested it on several emulators and a prehistoric Samsung Galaxy Gio with Android 2.3.3 and Nexus 5 with Android 5.1.1.


1 Answers

I figured it how, I ended up manually clearing each cookies for each host key.

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=");
like image 60
Raphael Marco Avatar answered Sep 28 '22 03:09

Raphael Marco