title: How can I retrieve the cookies from a POST request?
body: <p>I can send POST requests using <code>org.apache.http.clien.HttpClient</code> and get the HTTP response. But I don´t get the HTML content when logged in because my PHP script requires a cookie. So, how can I read the cookie of the POST request response and send it back using a GET request after the POST request?</p>
  
  <pre><code>    HttpClient httpClient = new DefaultHttpClient();
  
      List&lt;NameValuePair&gt; nameValuePairs = new ArrayList&lt;NameValuePair&gt;(); 
      nameValuePairs.add(new BasicNameValuePair("username", "user"));  
      nameValuePairs.add(new BasicNameValuePair("password", "passwd"));  
  
      HttpPost httpPost = new HttpPost("http://localhost/index.php");
      httpPost.setEntity(new UrlEncodedFormEntity(nameValuePairs));
  
      HttpResponse httpResponse = httpClient.execute(httpPost);
  
      BufferedInputStream bis = new BufferedInputStream(httpResponse.getEntity().getContent()); // Just gets the HTML content, not the cookies
  </code></pre>