title: Get and store cookie (from Set-Cookie) from an AJAX POST response
body: <p>I have a simple jQuery AJAX POST code:</p>
  
  <pre><code>$.ajax({
      type: "POST",
      url: AppConstants.URLs.PROXY,
      data: message,
      xhrFields: {
          withCredentials: true
      },
      success: function(data, status, xhr) {
          console.log("Cookie: " + xhr.getResponseHeader("Set-Cookie"));
      }
  });
  </code></pre>
  
  <p>and I wish to get the cookie and save it using <a href="https://www.npmjs.com/package/cookies-js" rel="noreferrer">cookies-js</a>.</p>
  
  <p>But according to <a href="http://www.w3.org/TR/XMLHttpRequest/#the-getallresponseheaders%28%29-method" rel="noreferrer">http://www.w3.org/TR/XMLHttpRequest/#the-getallresponseheaders%28%29-method</a>:</p>
  
  <blockquote>
    <ol start="3">
    <li>Return all response headers, <strong>excluding headers that are a case-insensitive match for Set-Cookie or Set-Cookie2</strong>, as a single string, with each header line separated by a U+000D CR U+000A LF pair, excluding the status line, and with each header name and header value separated by a U+003A COLON U+0020 SPACE pair.</li>
    </ol>
  </blockquote>
  
  <p>Using the Network tool in Chrome, "Set-Cookie" is visible in the Response headers. I also verified that the "Set-Cookie" header appears using <code>curl</code>.</p>
  
  <p>What do I have to do to save the cookie in my front end app? Also, my app is running on <strong>https</strong> only.</p>
  
  <p>I'd gladly provide more details upon request.</p>