title: Weird behaviour of httpcomponents
body: <p>I know that httpcomponents it's not a browser but I'm just using it to retrieve some cookies from a web server. The problem is that when I send an HTTP request I don't get the same set of cookies as when I navigate using Firefox. The site is www.amazon.com. I thought that it would be easy but I don't see which is the problem. Here is my code:</p>
  
  <pre><code>    DefaultHttpClient httpclient = new DefaultHttpClient();
  
      HttpGet httpget = new HttpGet("http://www.amazon.com");
  
      System.out.println("Initial set of cookies:");
      List&lt;Cookie&gt; cookies = httpclient.getCookieStore().getCookies();
      if (cookies.isEmpty()) {
          System.out.println("None");
      } else {
          for (int i = 0; i &lt; cookies.size(); i++) {
              System.out.println("- " + cookies.get(i).toString());
          }
      }
  
      HttpResponse response = null;
      try {
          response = httpclient.execute(httpget);
      } catch (ClientProtocolException e) {
          // TODO Auto-generated catch block
          e.printStackTrace();
      } catch (IOException e) {
          // TODO Auto-generated catch block
          e.printStackTrace();
      }
      HttpEntity entity = response.getEntity();
  
      System.out.println("Post logon cookies:");
      cookies = httpclient.getCookieStore().getCookies();
      if (cookies.isEmpty()) {
          System.out.println("None");
      } else {
          for (int i = 0; i &lt; cookies.size(); i++) {
              System.out.println("- " + cookies.get(i).toString());
          }
      }
  </code></pre>