Skip to content Skip to sidebar Skip to footer

Android Httpclient Cookie

Does Android HttpClient has auto-management for cookies?

Solution 1:

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?

Solution 2:

You can make it static and use it in all requests

client =  newOkHttpClient();  // client will be static and use in all requests CookieManagercookieManager=newCookieManager();
cookieManager.setCookiePolicy(CookiePolicy.ACCEPT_ALL);
client.setCookieHandler(cookieManager);

Post a Comment for "Android Httpclient Cookie"