【发布时间】:2010-11-18 01:31:21
【问题描述】:
Android HttpClient 有自动管理 cookie 的功能吗?
【问题讨论】:
标签: android cookies login httpclient
Android HttpClient 有自动管理 cookie 的功能吗?
【问题讨论】:
标签: android cookies login httpclient
它确实支持它。
阅读下面的帖子,您似乎在调用执行时必须传递相同的 HttpContext。
response = httpClient.execute(httpPost,localContext);
具体做法在这篇文章中:Android project using httpclient --> http.client (apache), post/get method
How do I manage cookies with HttpClient in Android and/or Java?
【讨论】:
您可以将其设为静态并在所有请求中使用它
client = new OkHttpClient(); // client will be static and use in all requests
CookieManager cookieManager = new CookieManager();
cookieManager.setCookiePolicy(CookiePolicy.ACCEPT_ALL);
client.setCookieHandler(cookieManager);
【讨论】: