title: How do Cookies Work in ASP.NET?
body: <p>The website where I work is made up of several projects (written in several languages). Right now we have to use some awkward code in query strings and session variables to keep a person logged in when they go from project to project. Since cookies are domain specific we're trying to convert to them since they can be set in one project using one language yet be accessed by a different project (on the same domain) using a different language. </p>
  
  <p>However I am having problems changing the value of a cookie and deleting them. Or to be more specific, I'm having trouble having any changes I make to a cookie stick.</p>
  
  <p>For example in my logout code:</p>
  
  <pre><code>if (Request.Cookies["thisuserlogin"] != null)
  {
      HttpCookie myCookie = new HttpCookie("thisuserlogin");
      myCookie.Value = String.Empty;
      myCookie.Expires = DateTime.Now.AddDays(-1d);
      Response.Cookies.Add(myCookie);
      Response.Cookies.Set(myCookie);
      litTest.Text = myCookie.Expires.ToString() + "&lt;br /&gt;" + Request.Cookies["thisuserlogin"].Expires.ToString();
  }
  </code></pre>
  
  <p>I wind up with one line being yesterday and the next line being 1/1/0001 12:00:00 even though they SHOULD be the same cookie. So why is it that even though the cookie was set, it's value did not change? Is there a way to force the user's computer to update a cookie's value, including deletion?</p>
  
  <p>Thank you very much.
  PS Any URLs you can provide to give an easy-to-understand primer for cookies would be appreciated.</p>