title: How to correct set the cookies for a subdomain in JSP?
body: <p>I have the following setup:</p>
  
  <ul>
  <li>all the requests are https (I will just omit this in the following description)</li>
  <li>3 docker servers: localhost:8090, localhost:8091, localhost:8092</li>
  <li>in hosts (on my windows machine) I have 3 domains: loc.localdomain, loc2.localdomain and loc3.localdomain all pointing to my IP address</li>
  <li>so I will use the localhost:8090 -> loc.localdomain, localhost:8091 -> loc2.localdomain and localhost:8092 -> loc3.localdomain in my apps</li>
  </ul>
  
  <p>Now I have an app on <code>loc</code> that sets some cookies for <code>loc3</code> subdomain. I see that the cookies are set (or suppose to be set) in chrome network response.</p>
  
  <pre><code>Set-Cookie: MY_COOKIE=YUMM; domain=loc3.localdomain; 
  expires=Fri, 21-Jun-2019 10:48:58 GMT; path=/coolApp/bro
  </code></pre>
  
  <p>Then in app at <code>loc</code> I have a button that sends the user in another app at <code>loc2</code> that redirects the user to <code>loc3</code> at <code>loc3.localdomain:8092/coolApp/bro/something/more</code>. So at this point in time I should see the cookie(s) in the app request at <code>loc3</code>, but I don't.</p>
  
  <p>Cookies setup:</p>
  
  <pre><code>FacesContext facesContext = FacesContext.getCurrentInstance();
  //facesContext.getExternalContext().addResponseCookie("TEST", "TEST", properties); tried this too 
  //then in properties will be the maxAge, path and domain set
  
  Cookie cookie = (Cookie) facesContext.getExternalContext().getRequestCookieMap().get("MY_COOKIE");
  if(cookie == null){
       cookie = new Cookie("MY_COOKIE", "YUMMM");
  }
  
  cookie.setMaxAge(31536000);
  cookie.setPath("/coolApp/bro");
  cookie.setDomain("loc3.localdomain"); // I've tried ".localdomain" too
  
  HttpServletResponse response = (HttpServletResponse) facesContext.getExternalContext().getResponse();
  response.addCookie(cookie);
  </code></pre>
  
  <p>Any idea what is wrong in this setup?</p>