当我在Android WebView中使用CookieManager时,我需要将Cookie标记为安全。 我怎么能这样做?
答案 0 :(得分:0)
试试这个。
CookieSyncManager.getInstance().sync();
String cookie = CookieManager.getInstance().getCookie(DOMAIN_NAME+COOKIE_PATH);
BasicCookieStore cookieJar = new BasicCookieStore();
if (!cookie.equals("")) {
String[] cookies = cookie.split(";");
for (int i = 0; i < cookies.length; i++) {
String[] nvp = cookies[i].split("=");
BasicClientCookie c = new BasicClientCookie(nvp[0], nvp[1]);
c.setDomain(DOMAIN_NAME);
c.setPath(COOKIE_PATH);
c.setSecure(true);
cookieJar.addCookie(c);
}
}