示例#1
0
        public void LoginButton_Click(object sender, EventArgs e)
        {
            SQLFunctions conn = new SQLFunctions();

            if (conn.authenticateUser(txtUserName.Text, txtPassword.Text) == true)
            {
                //Response.Redirect("index.aspx");
                FormsAuthenticationTicket tkt;
                string     cookiestr;
                HttpCookie ck;
                tkt       = new FormsAuthenticationTicket(1, txtUserName.Text, DateTime.Now, DateTime.Now.AddMinutes(30), true, "Extra data");
                cookiestr = FormsAuthentication.Encrypt(tkt);
                ck        = new HttpCookie(FormsAuthentication.FormsCookieName, cookiestr);

                ck.Expires = tkt.Expiration;
                ck.Path    = FormsAuthentication.FormsCookiePath;
                Response.Cookies.Add(ck);
                Response.Redirect("voting.aspx");
            }
            else
            {
                InvalidCredentialsMessage.Visible = true;
            }
        }