title: Why does Request.Cookies return string instead of HttpCookie object in foreach loop?
body: <p>This morning I accidentally saw the following snippet code, I was fairly surprised because it work very well.</p>
  
  <p>Don't look at its logic please, I'm just curious why does the HttpCookieCollection (Request.Cookies in this case) return a string (cookie name) instead of a HttpCookie object in foreach loop. Is it a consistency issue because we normally get HttpCookie object in this collection by index/name?</p>
  
  <p>Thanks,</p>
  
  <pre><code>foreach (string cookieKey in System.Web.HttpContext.Current.Request.Cookies)
  {
      HttpCookie tmpCookie = System.Web.HttpContext.Current.Request.Cookies[cookieKey];
      if (tmpCookie != null &amp;&amp; tmpCookie["RecentlyVisited"] != null)
      {
         cookie.Add(tmpCookie);
      }
  }
  </code></pre>