I am using HttpClient 4.1.2
HttpGet httpget = new HttpGet(uri);
HttpResponse response = httpClient.execute(httpget);
So, how can I get the cookie values?
解决方案
Please Note: The first link points to something that used to work in HttpClient V3. Find V4-related info below.
This should answer your question
The following is relevant for V4:
...in addition, the javadocs should contain more information on cookie handling
and here is a tutorial for httpclient v4:
And here is some pseudo-code that helps (I hope, it's based only on docs):
HttpClient httpClient = new DefaultHttpClient();
// execute get/post/put or whatever
httpClient.doGetPostPutOrWhatever();
// get cookieStore
CookieStore cookieStore = httpClient.getCookieStore();
// get Cookies
List cookies = cookieStore.getCookies();
// process...
Please make sure you read the javadocs for ResponseProcessCookies and AbstractHttpClient.