Based on the additional information, you want to save additional data using the FormsAuthentication ticket. To do this, you first need to create a custom FormsAuthentication ticket:
Data storage
Take the current HttpContext (without worrying about testability)
var httpContext = HttpContext.Current;
Determine when the ticket expires:
var expires = isPersistent ? DateTime.Now.Add(FormsAuthentication.Timeout) : NoPersistenceExpiryDate;
Create a new FormsAuthentication ticket to save your user data.
var authenticationTicket = new FormsAuthenticationTicket( 1, username, DateTime.Now, DateTime.Now.Add(FormsAuthentication.Timeout), isPersistent, "My Custom Data String");
Create your HTTP cookie
new HttpCookie(FormsAuthentication.FormsCookieName, FormsAuthentication.Encrypt(authenticationTicket)) { Path = FormsAuthentication.FormsCookiePath, Domain = FormsAuthentication.CookieDomain, Secure = FormsAuthentication.RequireSSL, Expires = expires, HttpOnly = true };
And finally add the answer
httpContext.Response.Cookies.Add(cookie);
Data retrieval
Then you can get data about subsequent requests by analyzing the stored authentication ticket ...
Grab the current HttpContext again
var httpContext = HttpContext.Current
Check if the request has been authenticated (call to Application_AuthenticateRequest or OnAuthorize)
if (!httpContext.Request.IsAuthenticated) return false;
Check if you have a ticket for FormsAuthentication and that it has not expired:
var formsCookie = httpContext.Request.Cookies[FormsAuthentication.FormsCookieName]; if (formsCookie == null) return false;
Get a FormsAuthentication Ticket:
var authenticationTicket = FormsAuthentication.Decrypt(formsCookie.Value); if (authenticationTicket.Expired) return false;
And finally, extract your data:
var data = authenticationTicket.UserData;