title: Delete cookie issue in C#
body: <p>I'm trying to delete a cookie, however it doesn't get deleted. Here is the code I try to use.</p>
  
  <pre><code>if (Request.Cookies["dcart"] != null)
  {
      Response.Write(Request.Cookies["dcart"].Expires);
      // Response 1/1/0001 12:00:00 AM
  
      Response.Write(Request.Cookies["dcart"].Value);
      // Response 229884
  
      HttpCookie myCookie = new HttpCookie("dcart");
      myCookie.Expires = DateTime.Now.AddDays(-1d);
      myCookie.Value = "";
      Response.Cookies.Add(myCookie);
  }
  
  Response.Write(Request.Cookies["dcart"].Expires);
  // Response 1/1/0001 12:00:00 AM
  Response.Write(Request.Cookies["dcart"].Value);
  // Response 229884
  </code></pre>
  
  <p>When I retrieve the cookie again, nothing changes. I check w/ FireFox and Chrome same behavior. Interesting point is that expiration date shows correctly on the browsers but on the code.</p>
  
  <p>I tried followings and didn't work.</p>
  
  <ul>
  <li>Set expiration day to (tomorrow) and again set it for yesterday.</li>
  <li>Restart the browser (happens different browsers and people)</li>
  <li>Set the value something</li>
  <li>Use HttpContext.Current.Request.Cookies["dcart"]....</li>
  <li>Request.Cookies["dcart"].Expires = DateTime.Now.AddYears(-10);</li>
  </ul>
  
  <p>PS. The code won't work directly on your machine, because you don't have the cookie.</p>