model view controller - Storing more information using FormsAuthentication -


i want store more information in same cookie. can add values authentication cookie or have use second http cookie? want add firstname, lastname, return firstname lastname

 public void signin(p_userlogon_list_result user, bool createpersistentcookie)     {         if (user == null)             throw new argumentnullexception("user");         if (user.username == "administrator")         {             user.role_name = "administrator";             var cookie = new labcookie             {                 username = user.username,                 firstname = user.name,                 lastname = user.family,                 rememberme = false,              // roles = new list<string> { "administrator" }                  roles = new list<string> { user.role_name ?? "user" }             };             string userdata = jsonconvert.serializeobject(cookie);             var ticket = new formsauthenticationticket(1, cookie.username, datetime.now,                                                        datetime.now.add(formsauthentication.timeout),                                                        createpersistentcookie, userdata);             string encticket = formsauthentication.encrypt(ticket);             var httpcookie = new httpcookie(formsauthentication.formscookiename, encticket) { expires = datetime.now.add(formsauthentication.timeout) };              _httpcontext.response.cookies.add(httpcookie);         }      }   public class labidentity : iidentity {     public labidentity(formsauthenticationticket ticket)     {         if (ticket == null)         {             name = "guest";             roles = new list<string> { "guest" };             return;         }          var data = jsonconvert.deserializeobject<labcookie>(ticket.userdata);          if (data == null)         {             asguest();             return;         }           username = data.username;           firstname = data.firstname;           lastname = data.lastname;           name = username;          //email = data.email;         roles = data.roles ?? new list<string> { "user" };         rememberme = data.rememberme;       }       private void asguest()     {         name = "guest";         roles = new list<string> { "guest" };     }      public string username { get; set; }     //public string email { get; set; }     public string firstname { get; set; }     public string lastname { get; set; }     //public timezoneinfo timezone { get; set; }     public bool rememberme { get; set; }     public ilist<string> roles { get; set; }      #region iidentity members      public string authenticationtype     {         { return "labportal"; }     }      public bool isauthenticated     {         { return !string.isnullorempty(username); }     }      public string name { get; protected set; }      #endregion } 


Popular posts from this blog

c# - ODP.NET Oracle.ManagedDataAccess causes ORA-12537 network session end of file -

matlab - Compression and Decompression of ECG Signal using HUFFMAN ALGORITHM -

utf 8 - split utf-8 string into bytes in python -