public static void RegisterTicket(AR2AP.WebApp.Models.CurrEmpData currUserData) { string strUserData = CreateTicketUserData(currUserData); FormsAuthenticationTicket ticket = new FormsAuthenticationTicket(1, currUserData.Username, DateTime.Now, DateTime.Now.Add(FormsAuthentication.Timeout), true, strUserData); HttpCookie cookie = new HttpCookie(FormsAuthentication.FormsCookieName, FormsAuthentication.Encrypt(ticket)); HttpContext.Current.Response.Cookies.Add(cookie); }
private static AR2AP.WebApp.Models.CurrEmpData GetCurrUserDataFromTicket(string strUserData) { string[] userInfoArray = strUserData.Split(','); if (userInfoArray.Length != 3) { throw new ArgumentException("strUserData"); } AR2AP.WebApp.Models.CurrEmpData rtnValue = new AR2AP.WebApp.Models.CurrEmpData(); rtnValue.EmpID = int.Parse(userInfoArray[0]); rtnValue.EmpName = userInfoArray[1]; rtnValue.Username = userInfoArray[2]; return(rtnValue); }
private static string CreateTicketUserData(AR2AP.WebApp.Models.CurrEmpData currUserData) { string strUserInfo = string.Format("{0},{1},{2}", currUserData.EmpID, currUserData.EmpName, currUserData.Username); return(strUserInfo); }