title: JSESSIONID cookie not stored
body: <p>I have a frontend written in angular which runs on localhost:3002.
  I have a backend written with Spring-boot which runs on localhost:8080.</p>
  
  <p>I added a filter to handle CORS (which I found on SO and adapted to my need) : </p>
  
  <pre><code>@Component
  public class CORSFilter implements Filter {
  
      @Override
      public void init(FilterConfig filterConfig) throws ServletException {
      }
  
      @Override
      public void doFilter(ServletRequest request, ServletResponse res, FilterChain chain) throws IOException, ServletException {
          HttpServletResponse response = (HttpServletResponse) res;
          response.setHeader("Access-Control-Allow-Origin", "http://localhost:3002");
          response.setHeader("Access-Control-Allow-Methods", "POST, GET, OPTIONS, DELETE, PUT");
          response.setHeader("Access-Control-Max-Age", "3600");
          response.setHeader("Access-Control-Allow-Credentials", "true");
          response.setHeader("Access-Control-Allow-Headers", "x-requested-with");
          chain.doFilter(request, response);
      }
  
      public void destroy() {}
  }
  </code></pre>
  
  <p>When I authenticate, I can see that the server sends a cookie : </p>
  
  <p><a href="https://i.stack.imgur.com/OPl0q.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/OPl0q.png" alt="enter image description here"></a></p>
  
  <p>This cookie is not sent with the following requests. This results in 401 responses : </p>
  
  <p><a href="https://i.stack.imgur.com/8KPHm.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/8KPHm.png" alt="enter image description here"></a></p>
  
  <p>I looked at the "resources" panel of the chrome console and found out that no cookie were stored.</p>
  
  <p>Any ideas?</p>