title: Why is my cookie not set?
body: <p>I am playing around again with ASP.NET, and tried to set a cookie in one action which will be read in another action.</p>
  
  <p>The strange thing is: the cookie gets set, but looses its value when accessing another page. Here is my simple controller code:</p>
  
  <pre><code>public class HomeController : Controller
  {
      public ActionResult About()
      {
          var cookie = Response.Cookies.Get("sid");
          ViewData["debug"] = "Id: " + cookie.Value;
  
          return View();
      }
  
      public ActionResult DoLogin()
      {
          var cookie = new HttpCookie("sid", Guid.NewGuid().ToString());
          cookie.HttpOnly = true;
          Response.Cookies.Add(cookie);
  
          return RedirectToAction("About");
      }
  }
  </code></pre>
  
  <p>The flow is like this: first I access <code>/Home/DoLogin</code>, then I get redirected to <code>/Home/About</code> which should actually output the value of the <code>sid</code> cookie. But the cookie does not have any value. </p>
  
  <ul>
  <li>Cookies are not disabled in my browser</li>
  <li>I know that ASP.NET has its own session handling mechanism, just playing around and stumbled upon this cookie problem</li>
  </ul>
  
  <p>Thanks for any hints!</p>