1、cookie的获取
CookieManager cookieManager = CookieManager.getInstance();
String cookieStr = cookieManager.getCookie(url);
2、cookie的设置
CookieSyncManager.createInstance(context);
CookieManager cookieManager = CookieManager.getInstance();
cookieManager.setAcceptCookie(true);
cookieManager.removeAllCookie();
cookieManager.removeSessionCookie();//移除
cookieManager.setCookie(url, cookie);//cookies是在HttpClient中获得的cookie
CookieSyncManager.getInstance().sync();
注:cookie一般为一个key-value字符串,如果cookie有两对字符串,或者更多,需要多次setCookie(),否则webview只会获取第一对。