FormsAuthenticationTicket ticket = new FormsAuthenticationTicket(1, this.tbName.Text, DateTime.Now, DateTime.Now.AddMinutes(30), this.PersistCookie.Checked, "User");
string cookieStr = FormsAuthentication.Encrypt(ticket);
HttpCookie cookie = new HttpCookie(FormsAuthentication.FormsCookieName, cookieStr);
if (this.PersistCookie.Checked)
{
cookie.Expires = ticket.Expiration;
}
cookie.Path = FormsAuthentication.FormsCookiePath;
Response.Cookies.Add(cookie);
lbUser.Text = "The UserName is " + tbName.Text;
if (tbName.Text == "John")
{
lbSf.Text = "The Role is " + "admin";
}
else
{
lbSf.Text = "The Role is " + "user";
}
FormsAuthentication.RedirectFromLoginPage(tbName.Text, false);