Fabian
Fabian

Reputation: 101

Android HttpClient Cookie

Does Android HttpClient has auto-management for cookies?

Upvotes: 10

Views: 18177

Answers (2)

Yousef Zakher
Yousef Zakher

Reputation: 1544

You can make it static and use it in all requests

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

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

Upvotes: 0

Patrick Boos
Patrick Boos

Reputation: 7029

It does support it.

Reading the posts below it seems like you have to pass the same HttpContext when calling execute.

response = httpClient.execute(httpPost,localContext); 

exactly how to do is in this post: Android project using httpclient --> http.client (apache), post/get method

How do I manage cookies with HttpClient in Android and/or Java?

Upvotes: 6

Related Questions