protected void Login_Auth() { try { ObjUser = new RegistrationHelper(); _Login = txtUsername.Text.Trim(); _Password = txtPassword.Text.Trim(); if ((_Login != "") && (_Password != "")) { HttpCookie UserLogin = new HttpCookie("LOGIN"); UserLogin.Value = _Login; UserLogin.Value = _Password; Response.Cookies.Add(UserLogin); Response.Cookies["UserLogin"].Value = _Login; Response.Cookies["UserLogin"].Value = _Password; DT = ObjUser.Loginuser(_Login, _Password); if (DT.Rows.Count > 0) { Session["Login"] = _Login; //Login1.FailureText = ""; if (chkRemember.Checked == true) { //Check if the browser support cookies if (Request.Browser.Cookies) { //Check if the cookie with name PBLOGIN exist on user's machine if (Request.Cookies["LOGIN"] == null) { //Create a cookie with expiry of 30 days Response.Cookies["LOGIN"].Expires = DateTime.Now.AddDays(30); //Write username to the cookie Response.Cookies["UserLogin"].Value = null; Response.Cookies["UserLogin"].Value = null; Response.Cookies["UserLogin"].Value = null; Response.Cookies["UserLogin"].Value = null; Response.Cookies.Clear(); } //If the cookie already exist then write the user name and password on the cookie else { Response.Cookies["UserLogin"].Value = _Login; Response.Cookies["UserLogin"].Value = _Password; } } else { Response.Cookies.Clear(); Response.Cookies["UserLogin"].Value = null; Response.Cookies["UserLogin"].Value = null; Response.Cookies["UserLogin"].Value = null; Response.Cookies["UserLogin"].Value = null; } } else { Response.Cookies.Clear(); Response.Cookies["UserLogin"].Value = null; Response.Cookies["UserLogin"].Value = null; Response.Cookies["UserLogin"].Value = null; Response.Cookies["UserLogin"].Value = null; } string Info = "welcome.aspx?userId=" + txtUsername.Text.Trim(); Response.Redirect(Info, false); // Response.Redirect("Welcome.aspx"); Clear(Page); } else { ScriptManager.RegisterClientScriptBlock(Page, Page.GetType(), "Exception", "alert('Login Attempt Not successfull');", true); } } else { ScriptManager.RegisterClientScriptBlock(Page, Page.GetType(), "Exception", "alert('Fill a User Name ID & Password');", true); } } catch (Exception ex) { ScriptManager.RegisterClientScriptBlock(Page, Page.GetType(), "Exception", "alert('" + ex.Message + "');", true); } finally { txtPassword.Text = ""; Clear(Page); txtUsername.Focus(); } }