I'm looking for some guidance with respect to cookies in ASP.Net MVC (or just cookie handling in general). I have been storing authentication information about users who authenticate via a form login in a cookie. This is working great, but I now need to store a little more information in the cookie. This additional information is not really "authentication related" so I'm hesitant to store it in the authentication ticket. Is there a better practice for storing extra information. Is it possible to set multiple cookies (and if so is that a good/bad practice)? Other things I should be considering here?
Here is the current code I'm using to set the authentication ticket and wrap it in a cookie:
private HttpCookie GetAuthCookie(AuthToken authToken)
{
var authTokenXml = serializationService.Serialize(authToken);
var authCookieString = FormsAuthentication.Encrypt(
new FormsAuthenticationTicket(
0,
Keys.AuthToken,
DateTime.Now,
DateTime.Now.AddMinutes(AppSettings.SessionTimeoutMinutes),
true,
authTokenXml));
var cookie = new HttpCookie(FormsAuthentication.FormsCookieName, authCookieString)
{
Expires = DateTime.Now.AddDays(AppSettings.AuthCookieExpireDays)
};
return cookie;
}