android webview 设置cookie 需要注意

PHP=5780bcb929f8276e73c273dc5a71a470; expires=Wed, 09-Dec-2015 05:18:30 GMT; path=/; domain=.xxx.com

expires时间必须有效,不然不会加入到wenview之中 而且domain=.xxx.com和url的domain 必须要匹配,不然.setCookie无效

CookieSyncManager.createInstance(context);
CookieManager cookieManager = CookieManager.getInstance();
cookieManager.setAcceptCookie(true);
cookieManager.removeSessionCookie();// 移除
cookieManager.removeAllCookie();
cookieManager.setCookie(url,
PreferencesUtil.getString(Logininfo.Cookie, "PHP="));// cookies是在HttpClient中获得的cookie



CookieSyncManager.getInstance().sync();

你可能感兴趣的:(android webview 设置cookie 需要注意)