WebView添加cookie

public void synCookies(String url,String cookies) { 
LogUtil.d(tag, "synCookies:"+url);
    CookieSyncManager.createInstance(mContext); 
    CookieManager cookieManager = CookieManager.getInstance(); 
    cookieManager.setAcceptCookie(true); 
    LogUtil.d(tag, "cookie:"+cookies);
    cookieManager.setCookie(url, cookies);//cookies是在HttpClient中获得的cookie 
    CookieSyncManager.getInstance().sync(); 
  
    LogUtil.d(tag, "cookie:"+cookieManager.getCookie(url));
}

 String cookies = "sid=" + sessionId +";domain=域名;";

你可能感兴趣的:(webView)