Android CookieManager getCookie问题 [英] Android CookieManager getCookie issue

查看:107
本文介绍了Android CookieManager getCookie问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用cookiemanager setcookie API设置cookie,当我执行cookiemanager getcookie时,我没有获得域&以下是我的验证码.

I am setting a cookie using cookiemanager setcookie API, when I do cookiemanager getcookie I am not getting the domain & expiry date below is my code.

String cookieString = cookie.getName() + "=" + cookie.getValue() + "; Domain=" + cookie.getDomain()+"; expires=" + cookie.getExpiryDate();
CookieManager.getInstance().setCookie("http://mydomainname.com", cookieString);

 String cookie = CookieManager.getInstance().getCookie("http://mydomainname.com");

任何想法,为什么cookiemanager getcookie不返回域&到期日.这是一个错误吗?

Any idea why cookiemanager getcookie doesn't return domain & expiry date. Is it a bug ?

谢谢,库玛.

推荐答案

不是bug-只需阅读文档即可.Android API文档说getCookie()返回一个字符串使用'Cookie'HTTP请求标头的格式"

Not a bug - just read the documentation. The Android API docs say that getCookie() returns a string "using the format of the 'Cookie' HTTP request header"

Cookie:请求标头的格式是由分号分隔的Cookie名称/值对的列表-它不包含域或有效期信息,因为仅当URL匹配且未过期时才发送Cookie.CookieManager.getCookie()方法的作用相同-它返回所有与提供的URL匹配且尚未过期的cookie.

The format of the Cookie: request header is a list of cookie name/value pairs separated by semicolons - it does NOT contain domain or expiry information, since a cookie is sent only if the URL matches and it has not expired. The CookieManager.getCookie() method does the same - it returns all the cookies that match the URL supplied and which have not expired.

这篇关于Android CookieManager getCookie问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆