public class CookiesGet {
public static void main(String[] args) throws IOException {
BasicCookieStore cookieStore = new BasicCookieStore();
CloseableHttpClient httpClient = HttpClients.custom().setDefaultCookieStore(cookieStore).build();
List<NameValuePair> list = new ArrayList<>();
list.add(new BasicNameValuePair("m","Home"));
list.add(new BasicNameValuePair("c","Cart"));
list.add(new BasicNameValuePair("a","header_cart_list"));
UrlEncodedFormEntity formEntity = new UrlEncodedFormEntity(list);
String params = EntityUtils.toString(formEntity, "UTF-8");
HttpGet get = new HttpGet("http://www.xxxxxxx.com?"+params);
CloseableHttpResponse httpResponse = httpClient.execute(get);
httpClient.close();
if(httpResponse.getStatusLine().getStatusCode() == 200){
List<Cookie> cookies = cookieStore.getCookies();
for(Cookie cookie :cookies){
System.out.println(cookie.getName() + ":"+ cookie.getValue());
}
}
httpClient.close();
}
}