title: After upgrading to Apache HttpClient 4.4 it does not send cookies with requests
body: <p>I am using the Apache HttpClient to send requests to our internal API servers. The servers require authentication and need a cookie to be set with an auth token.</p>
  
  <p>Up to HttpClient 4.3.6 this has been working fine, but on 4.4 and above it has stopped sending the cookies on requests. My cookie domain is set to .subdomain.mycompany.com, which works for 4.3.6, but not 4.4 and above. If I'm more specific and give the full host as the cookie domain, i.e. host.subdomain.mycompany.com it works, but this is not a solution.</p>
  
  <p>Here's a code snippet similar to what I'm doing:</p>
  
  <pre><code>public CloseableHttpResponse execute(CloseableHttpClient httpClient) throws IOException {
      BasicClientCookie cookie = new BasicClientCookie("cookieName", "myAuthtoken");
      cookie.setPath("/");
      cookie.setDomain(".subdomain.mycompany.com");
      cookie.setSecure(false);
      HttpContext localContext = new BasicHttpContext(parentContext);
      CookieStore cookieStore = new BasicCookieStore();
      cookieStore.addCookie(cookie);
      localContext.setAttribute(HttpClientContext.COOKIE_STORE, cookieStore);
      return httpClient.execute(target, request, localContext);
  }
  </code></pre>
  
  <p>The httpClient is already constructed and passed into this code which sets the auth cookie.</p>
  
  <p>I saw this, which is similar <a href="https://stackoverflow.com/questions/29970409/cookies-getting-ignored-in-apache-httpclient-4-4">Cookies getting ignored in Apache httpclient 4.4</a>, but in my case the cookies aren't being sent to the server.</p>
  
  <p>After turning on wire logging in the HttpClient I can see the following in 4.3.6, but not in 4.4 and above:</p>
  
  <pre><code>DEBUG [org.apache.http.client.protocol.RequestAddCookies] Cookie [version: 0][name: cookieName][value: authToken][domain: .subdomain.mycompany.com][path: /][expiry: Wed Jul 15 16:07:05 IST 2015] match [host.subdomain.mycompany.com:80/myApi]
  </code></pre>
  
  <p>Which leads me to think it's something to do with cookie domain matching. Anyone have any ideas? Thanks.</p>