You get your cookies from HttpResponse response
:
Header[] mCookies = response.getHeaders("cookie");
and add them to your next request:
HttpClient httpClient = new DefaultHttpClient();
//parse name/value from mCookies[0]. If you have more than one cookie, a for cycle is needed.
CookieStore cookieStore = new BasicCookieStore();
Cookie cookie = new BasicClientCookie("name", "value");
cookieStore.addCookie(cookie);
HttpContext localContext = new BasicHttpContext();
localContext.setAttribute(ClientContext.COOKIE_STORE, cookieStore);
HttpGet httpGet = new HttpGet("http://www.domain.com/");
HttpResponse response = httpClient.execute(httpGet, localContext);
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…