Android HttpClient Cookie
Asked Answered
G

2

10

Does Android HttpClient has auto-management for cookies?

Gunpowder answered 18/11, 2010 at 1:31 Comment(0)
S
6

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?

Silber answered 18/11, 2010 at 2:12 Comment(0)
C
0

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);
Captainship answered 27/12, 2014 at 1:0 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.