title: How to check, if browser has cookies enabled in web app?
body: <p>I decided to re-write the question as I found some info on how to accomplish the above:
  <a href="http://msdn.microsoft.com/en-us/library/aa289495%28v=vs.71%29.aspx" rel="nofollow">http://msdn.microsoft.com/en-us/library/aa289495%28v=vs.71%29.aspx</a></p>
  
  <p>However, my problem is that I'm trying to do all that on the <code>Page_Load</code> event of <code>Login.aspx.cs</code>.</p>
  
  <p>Initially it appears to be working fine until I attempt to actually log in by entering my credentials and clicking the Login button. Then all hell breaks lose and I get an endless loop. It keeps going back and forth between Page_Loads on <code>Login.aspx.cs</code> and <code>TestForCookies.aspx.cs</code>. Each time Redirect URL grows by another <code>"?AcceptCookies=1</code>". Is there a work around to this?</p>
  
  <p>Login.aspx.cs code:</p>
  
  <pre><code>protected void Page_Load(object sender, EventArgs e)
  {
      if (!Page.IsPostBack)
      {
          if (Request.QueryString["AcceptsCookies"] == null)
          {
              Response.Cookies["TestCookie"].Value = "ok";
              Response.Cookies["TestCookie"].Expires = DateTime.Now.AddMinutes(1);
              Response.Redirect(BasePage.ResolveUrl("~/Common/TestForCookies.aspx?redirect=" + Server.UrlEncode(Request.Url.ToString())));
          }
          else
          {
              LoginBox.InstructionText = "Accept cookies = " + Request.QueryString["AcceptsCookies"];
          }
      }
  
  }
  </code></pre>
  
  <p>TestForCookies.aspx.cs code:</p>
  
  <pre><code>protected void Page_Load(object sender, EventArgs e)
  {
      string redirect = Request.QueryString["redirect"];
  
      string acceptsCookies = null;
      // Was the cookie accepted?
      if (Request.Cookies["TestCookie"] == null)
      {
          // No cookie, so it must not have been accepted
          acceptsCookies = "0";
      }
      else
      {
          acceptsCookies = "1";
          // Delete test cookie
          Response.Cookies["TestCookie"].Expires = DateTime.Now.AddDays(-1);
      }
  
      string url = redirect + "?AcceptsCookies=" + acceptsCookies;
  
  
      Response.Redirect(url);
  }
  </code></pre>