protected void btnAcesso_Click(object sender, EventArgs e) { try { FuncionarioBusiness business = new FuncionarioBusiness(); int login = int.Parse(txtLogin.Text); Funcionario f = business.Autenticar(login, txtSenha.Text); string matricula = Convert.ToString(f.Matricula); FormsAuthenticationTicket ticket = new FormsAuthenticationTicket(matricula, false, 5); HttpCookie cookie = new HttpCookie(FormsAuthentication.FormsCookieName, FormsAuthentication.Encrypt(ticket)); Response.Cookies.Add(cookie); Session["user"] = f; Response.Redirect("/AreaRestrita/Home.aspx"); } catch (Exception ex) { lblMensagemAcessar.Text = ex.Message; lblMensagemAcessar.ForeColor = Color.Red; } }