protected void cmdLoginAdmin_Click(object sender, EventArgs e) { using (PTCLEntities db = new PTCLEntities()) { var password = txtPassword.Text; var salt = CreateSalt(); var hash = HashPassword(password, salt); var query = db.PtclAdminLogin(txtUserName.Text, Convert.ToBase64String(hash)).ToList(); //var query = db.PtclAdminLogin(txtUserName.Text, txtPassword.Text).ToList(); if (query.Count > 0) { Session["AdminID"] = query[0].AdminID; Session["UserName"] = query[0].UserName; Session.Timeout = 720; Response.Cookies["PCS"]["AdminID"] = query[0].AdminID.ToString(); Response.Cookies["PCS"]["UserName"] = query[0].UserName.ToString(); Response.Cookies["PCS"].Expires = DateTime.Now.AddDays(3); ; Response.Redirect("Home.aspx"); } else { lblMsg.Text = "Invalid Username or Password"; } } }