protected void cmdLoginUser_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.PtclUserLogin(txtEmail.Text, Convert.ToBase64String(hash)).ToList(); //var query = db.PtclUserLogin(txtEmail.Text, txtPassword.Text).ToList(); if (query.Count > 0) { Session["UserID"] = query[0].UserID; Session["FirstName"] = query[0].FirstName; Session.Timeout = 720; Response.Cookies["PCS"]["UserID"] = query[0].UserID.ToString(); Response.Cookies["PCS"]["FirstName"] = query[0].FirstName.ToString(); Response.Cookies["PCS"].Expires = DateTime.Now.AddDays(1); Response.Redirect("Home.aspx"); } else { lblMsg.Text = "Invalid Email or Password"; } } }