title: How to best check if a cookie exists?
body: <p>I was trying to determine if a cookie existed and if it had expired with this code:</p>
  
  <pre><code>if(HttpContext.Current.Response.Cookies["CookieName"]){
      Do stuff;
  }
  </code></pre>
  
  <p>However after long hours of tears and sweat I noticed that this line was actually creating a blank cookie or overwriting the existing cookie and its value to be blank and expire at 0.</p>
  
  <p>I solved this by doing reading ALL the cookies and looking for a match like that instead</p>
  
  <pre><code>if (context.Response.Cookies.AllKeys.Contains("CookieName"))
          {
              Do stuff;
          }
  </code></pre>
  
  <p>This doesn't seem optimal, and I find it weird that my initial attempt created a cookie.
  Does anyone have a good explanation to cookie?</p>