Ejemplo n.º 1
0
        private void AddCookieAndRedirect(User user)
        {
            var customData = new TicketUserData {
                UserId = user.Id, UserRole = user.Role
            };
            var expiration = DateTime.Now.AddDays(1);
            var ticket     = new FormsAuthenticationTicket(1, user.Email, DateTime.Now, expiration, false, customData.ToString());
            var cookie     = new HttpCookie(FormsAuthentication.FormsCookieName, FormsAuthentication.Encrypt(ticket));

            Response.Cookies.Add(cookie);
        }
Ejemplo n.º 2
0
        public static string GetStructuredUserData(IPrincipal user, TicketUserData keyName)
        {
            var ticketData = GetStructuredUserData(user);

            return(ticketData[keyName.ToString()]);
        }
Ejemplo n.º 3
0
 public static string GetStructuredUserData(IPrincipal user, TicketUserData keyName)
 {
     var ticketData = GetStructuredUserData(user);
     return ticketData[keyName.ToString()];
 }