Delete all cookies from a specific domain in a web view

I am trying to delete all cookies from a domain, is there any way to do this?

The only method I've seen is removeAllCookies.

Thanks.

+4
source share
2 answers

According to the documentation , we have no way to delete individual cookies. But we could use some interesting work with setCookie()to clear the site’s cookies. as,

public abstract void setCookie (String url, String value)

cookie URL. cookie , cookie. cookie , .

, : this, cookie . : - 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=");
+5

, CookieManager, cookie, WebView. cookie removeAllCookie(), API 21, removeAllCookeis(callback), null , , - cookie , Looper.

cookie ,

CookieManager.getInstance().removeAllCookies(null);
CookieManager.getInstance().flush();

CookieSyncManager cookieSyncMngr=CookieSyncManager.createInstance(context);
cookieSyncMngr.startSync();
CookieManager cookieManager=CookieManager.getInstance();
cookieManager.removeAllCookie();
cookieManager.removeSessionCookie();
cookieSyncMngr.stopSync();
cookieSyncMngr.sync();
+4

Source: https://habr.com/ru/post/1628697/


All Articles