Android HttpClient Cookie

时间:2010-11-18 01:31:21

标签: android cookies login httpclient

Android HttpClient是否对Cookie有自动管理功能?

2 个答案:

答案 0 :(得分:6)

确实支持它。

阅读下面的帖子似乎你必须在调用execute时传递相同的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?

答案 1 :(得分:0)

您可以将其设置为静态并在所有请求中使用

client =  new OkHttpClient();  // client will be static and use in all requests 

CookieManager cookieManager = new CookieManager();
cookieManager.setCookiePolicy(CookiePolicy.ACCEPT_ALL);
client.setCookieHandler(cookieManager);