protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
// Check if the browser supports cookies
if (Request.Browser.Cookies)
{
if (Request.QueryString["CheckCookie"] == null)
{
// Create the test cookie object
HttpCookie cookie = new HttpCookie("TestCookie", "1");
Response.Cookies.Add(cookie);
// Redirect to the same webform
Response.Redirect("Default.aspx?CheckCookie=1");
}
else
{
//Check the existence of the test cookie
HttpCookie cookie = Request.Cookies["TestCookie"];
if (cookie == null)
{
lblMessage.Text = "We have detected that, the cookies are disabled on your browser. Please enable cookies.";
}
}
}
else
{
lblMessage.Text = "Browser doesn't support cookies. Please install one of the modern browser's that support cookies.";
}
}
}
{
if (!IsPostBack)
{
// Check if the browser supports cookies
if (Request.Browser.Cookies)
{
if (Request.QueryString["CheckCookie"] == null)
{
// Create the test cookie object
HttpCookie cookie = new HttpCookie("TestCookie", "1");
Response.Cookies.Add(cookie);
// Redirect to the same webform
Response.Redirect("Default.aspx?CheckCookie=1");
}
else
{
//Check the existence of the test cookie
HttpCookie cookie = Request.Cookies["TestCookie"];
if (cookie == null)
{
lblMessage.Text = "We have detected that, the cookies are disabled on your browser. Please enable cookies.";
}
}
}
else
{
lblMessage.Text = "Browser doesn't support cookies. Please install one of the modern browser's that support cookies.";
}
}
}
No comments:
Post a Comment