title: How to set cookie in browser from ajax response
body: <p>I have a javascript function using jQuery to make a POST request to a web service.  The web service response has a header "Set-Cookie: name=value; domain=api.mydomain.com; path=/", and a JSON body.</p>
  
  <p>I expected the browser to set the cookie, but it does not.  Am I mistaken about how this should work?  Is there another way to make the browser set the cookie returned in the response header?</p>
  
  <pre><code>$.ajax(
      {
          type: "POST",
          url: "https://api.mydomain.com/service",
          data: body,
          success: handleSuccess,
          error: handleFailure
      }
  );
  </code></pre>