title: localhost cookies not set
body: <p>I'm trying to set a cookie in my application.</p>
  
  <p>Here's the code that sets the cookie:</p>
  
  <pre><code>public HttpResponseMessage LogIn(UserLoginVM user)
  {
      // Do login stuff
  
      var cookie = new CookieHeaderValue("STUPID-COOKIE", "12345");
      cookie.Domain = Request.RequestUri.Host;
      cookie.Path = "/";
      cookie.HttpOnly = true;
  
      // Get user's profile
  
      HttpResponseMessage res = Request.CreateResponse&lt;UserProfileVM&gt;(HttpStatusCode.OK, profile);
      res.Headers.AddCookies(new CookieHeaderValue[] { cookie });
  
      return res;
  }
  </code></pre>
  
  <p>The response from the server is the following:</p>
  
  <pre><code>HTTP/1.1 200 OK
  Cache-Control: no-cache
  Pragma: no-cache
  Content-Type: application/json; charset=utf-8
  Expires: -1
  Server: Microsoft-IIS/8.0
  Set-Cookie: STUPID-COOKIE=12345; domain=localhost; path=/; httponly
  Access-Control-Allow-Origin: *
  X-AspNet-Version: 4.0.30319
  X-SourceFiles: =?UTF-8?B?QzpcUFJPSkVDVFNcU2Ftc2tpcC5TZXJ2aWNlV2ViTmV3XFNhbXNraXAuQXV0aEFQSVxTYW1za2lwLkF1dGhBUElcbG9naW4=?=
  X-Powered-By: ASP.NET
  Date: Wed, 18 Feb 2015 11:58:07 GMT
  Content-Length: 8019
  </code></pre>
  
  <p>Notice the following header:</p>
  
  <pre><code>Set-Cookie: STUPID-COOKIE=12345; domain=localhost; path=/; httponly
  </code></pre>
  
  <p>However, when I go under "Cookies" in "Resources" tab in Chrome, nothing is set. Also when I send a request to the server no cookie is in the headers.</p>
  
  <p>Here's the code that reads the cookie:</p>
  
  <pre><code>CookieHeaderValue cookie = Request.Headers.GetCookies("STUPID-COOKIE").FirstOrDefault();
  </code></pre>
  
  <p><code>cookie</code> variable is always null.</p>
  
  <p>My application is running on <a href="http://localhost:53998" rel="noreferrer">http://localhost:53998</a> and the authentication service is running on <a href="http://localhost:60858" rel="noreferrer">http://localhost:60858</a></p>
  
  <p>My Chrome version is 40.0.2214.111.</p>
  
  <p>Here's a GIF demonstrating the problem:
  <a href="http://i.imgur.com/q7lkXBz.gif" rel="noreferrer">http://i.imgur.com/q7lkXBz.gif</a></p>
  
  <p><strong>Edit:</strong> This seems to be non-specific to Chrome. This doesn't work on FireFox (v35) either. GIF: <a href="http://i.imgur.com/ZewnEtc.gif" rel="noreferrer">http://i.imgur.com/ZewnEtc.gif</a></p>