|
// Get the
cookie created by the FormsAuthentication API // Notice
that this cookie will have all the attributes
according to // the
ones in the config file setting. HttpCookie
cookie = FormsAuthentication.GetAuthCookie(
UserId.Text,
false ); FormsAuthenticationTicket ticket =
FormsAuthentication.Decrypt(cookie.Value); // Store roles inside the Forms Ticket with all
the attributes aligned with
// the
config Forms section. FormsAuthenticationTicket newticket =
new
FormsAuthenticationTicket( ticket.Version, ticket.Name, ticket.IssueDate, ticket.Expiration, ticket.IsPersistent, String.Join( "|", roles), ticket.CookiePath); // add the
encrypted ticket to the cookie as data. cookie.Value =
FormsAuthentication.Encrypt(newticket); // Update
the outgoing cookies collection. Context.Response.Cookies.Set(cookie); //
Redirect the user to the originally requested
page Response.Redirect(
FormsAuthentication.GetRedirectUrl(
newticket.Name, newticket.IsPersistent ) );
|