Android中的HTTP cookie存储

Android中的HTTP cookie存储,第1张

Android中的HTTP cookie存储

您从

HttpResponse response
以下位置获取cookie :

Header[] mcookies = response.getHeaders("cookie");

并将它们添加到您的下一个请求中:

HttpClient httpClient = new DefaultHttpClient();//parse name/value from mcookies[0]. If you have more than one cookie, a for cycle is needed.cookieStore cookieStore = new BasiccookieStore();cookie cookie = new BasicClientcookie("name", "value");cookieStore.addcookie(cookie);HttpContext localContext = new BasicHttpContext();localContext.setAttribute(ClientContext.cookie_STORE, cookieStore);HttpGet httpGet = new HttpGet("http://www.domain.com/");HttpResponse response = httpClient.execute(httpGet, localContext);


欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/zaji/5489707.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-12-13
下一篇 2022-12-12

发表评论

登录后才能评论

评论列表(0条)

保存