示例#1
0
    protected void SubmitButton_Click(object sender, EventArgs e)
    {
        ClubBAIST cb = new ClubBAIST();

        if (cb.IsAuthenticated(UserEmail.Text, Password.Text))
        {
            User                      thisUser        = cb.ReadUser(UserEmail.Text);
            MembershipLevel           ml              = cb.ReadMembershipLevel(thisUser.MembershipLevel);
            FormsAuthenticationTicket authTicket      = new FormsAuthenticationTicket(1, UserEmail.Text, DateTime.Now, DateTime.Now.AddMinutes(30), false, ml.Description);
            string                    encryptedTicket = FormsAuthentication.Encrypt(authTicket);
            HttpCookie                authCookie      = new HttpCookie(FormsAuthentication.FormsCookieName, encryptedTicket);
            Response.Cookies.Add(authCookie);
            Response.Redirect(FormsAuthentication.GetRedirectUrl(UserEmail.Text, false));
        }
        else
        {
            Msg.Text = "Login failed, check username or password.";
        }
    }