title: ASP.NET Mvc Api: Set cookie then 302/303 Redirect loses the cookie
body: <p>I have an API action that returns a HttpResponseMessage.
  API address is like: <a href="http://localhost/login?authcode=xxx" rel="noreferrer">http://localhost/login?authcode=xxx</a></p>
  
  <p>The API action does some login authentication and redirects the user to either register or the welcome page. Code goes like:</p>
  
  <pre><code>var response = new HttpResponseMessage();
  var cookie = new CookieHeaderValue("token", "ThisIsTheTokenNeeded");
  response.Headers.AddCookies(new CookieHeaderValue[] { cookie });
  response.StatusCode = HttpStatusCode.Found;
  response.Headers.Location = new Uri("http://localhost/welcome.html");
  return response;
  </code></pre>
  
  <p>In welcome.html, I use "document.write(document.cookie)" and cannot see the cookie named "token". Some how it got lost. Could anyone tell me how to get this done or this architecture is not correct after all?</p>