title: How to check if cookies are enabled or disabled in asp.net?
body: <pre><code>protected void Page_Load(object sender, EventArgs e)
  {
      if (!IsPostBack)
      {
          if (Request.Browser.Cookies)
          {
              if (Request.QueryString["check"] == null)
              {
                  HttpCookie cookie = new HttpCookie("testcookie");
                  Response.Cookies.Add(cookie);
                  Response.Redirect("Default.aspx?check=1");
              }
              else
              {
                  HttpCookie cookie = Request.Cookies["testcookie"];
                  if(cookie==null)
                  {
                      Label1.Text = "enable cookies";
                  }
              }
          }
          else
          {
              Label1.Text = "cookies not supported:";
          }
      }
  }
  
  protected void Button1_Click(object sender, EventArgs e)
  {
      HttpCookie cookie = new HttpCookie("userinfo");
      cookie["name"] = TextBox1.Text;
      cookie["email"] = TextBox2.Text;
      //cookie.Expires = DateTime.Now.AddDays(30);
      Response.Cookies.Add(cookie);
      Response.Redirect("Default2.aspx");
  
  }
  </code></pre>
  
  <p>It's not working correctly.</p>