List of usage examples for android.webkit CookieManager removeExpiredCookie
@Deprecated public abstract void removeExpiredCookie();
From source file:Main.java
private static void clearCookiesForDomain(Context context, String domain) { // This is to work around a bug where CookieManager may fail to instantiate if CookieSyncManager // has never been created. CookieSyncManager syncManager = CookieSyncManager.createInstance(context); syncManager.sync();//from ww w .j a v a 2 s.com CookieManager cookieManager = CookieManager.getInstance(); String cookies = cookieManager.getCookie(domain); if (cookies == null) { return; } String[] splitCookies = cookies.split(";"); for (String cookie : splitCookies) { String[] cookieParts = cookie.split("="); if (cookieParts.length > 0) { String newCookie = cookieParts[0].trim() + "=;expires=Sat, 1 Jan 2000 00:00:01 UTC;"; cookieManager.setCookie(domain, newCookie); } } cookieManager.removeExpiredCookie(); }
From source file:com.kinsights.cookies.Cookies.java
public void clear() { CookieManager cookieManager = CookieManager.getInstance(); cookieManager.removeExpiredCookie(); cookieManager.removeSessionCookie(); cookieManager.removeAllCookie();/*from w w w . j a v a2 s . c o m*/ }
From source file:com.codename1.impl.android.AndroidImplementation.java
@Override public Vector getCookiesForURL(String url) { if (isUseNativeCookieStore()) { try {//w ww. ja v a2 s . c o m URI uri = new URI(url); CookieManager mgr = getCookieManager(); mgr.removeExpiredCookie(); String domain = uri.getHost(); String cookieStr = mgr.getCookie(url); if (cookieStr != null) { String[] cookies = cookieStr.split(";"); int len = cookies.length; Vector out = new Vector(); for (int i = 0; i < len; i++) { Cookie c = new Cookie(); String[] parts = cookies[i].split("="); c.setName(parts[0].trim()); if (parts.length > 1) { c.setValue(parts[1].trim()); } else { c.setValue(""); } c.setDomain(domain); out.add(c); } return out; } } catch (Exception ex) { com.codename1.io.Log.e(ex); } return new Vector(); } return super.getCookiesForURL(url); }