title: Set-Cookie in HTTP header is ignored with AngularJS
body: <p>I'm working on an application based on AngularJS on client side and Java for my API (Tomcat + Jersey for WS) on server side.</p>
  
  <p>Some path of my API are restricted, if the user doesn't have a session the response status returned is 401. On the client side, 401 http status are intercepted to redirect the user to the login page.</p>
  
  <p>Once the user is authenticated, I create a session on the server side <pre>httpRequest.getSession(true);</pre>
  and the response send to the client does have the Set-cookie instruction in its header :</p>
  
  <pre>
  Set-Cookie:JSESSIONID=XXXXXXXXXXXXXXXXXXXXX; Domain=localhost; Path=/api/; HttpOnly
  </pre>
  
  <p>The problem is that the cookie is never put on the client side. When I inspect cookie for localhost domain it's empty, so the next requests don't have this cookie in their header and client side still couldn't access to the restricted path of my API.</p>
  
  <p>The client and the server are on the same domain but they don't have the same path and the same port number :</p>
  
  <p>Client : <code>http://localhost:8000/app/index.html</code></p>
  
  <p>Server : <code>http://localhost:8080/api/restricted/</code></p>
  
  <p>Additional info : CORS is enabled on the both side :</p>
  
  <pre>"Access-Control-Allow-Methods", "GET, POST, OPTIONS"
  "Access-Control-Allow-Origin", "*"
  "Access-Control-Allow-Credentials", true</pre>
  
  <p>Any idea for making the Set-cookie works properly ?
  Is it an AngularJS related issue ? </p>