FormsAuthenticationTicket looses UserData



Upon logon I create a ticket and put some userdata in it:
FormsAuthenticationTicket ticket = new FormsAuthenticationTicket(
3, //Version
tUsername.Text, //Username
DateTime.Now, //Issue time
DateTime.Now.AddHours(1), //Expires every hour
false, //Don't persist cookie
"test data" //User_SecureID
);
//Hash the cookie for transport
string hash = FormsAuthentication.Encrypt(ticket);
cookie = new HttpCookie( FormsAuthentication.FormsCookieName, hash);
Response.Cookies.Add(cookie);

***Later on another aspx page I want to read that userdata but it alweays is
empty???
if (HttpContext.Current.User != null)
{

if (HttpContext.Current.User.Identity.IsAuthenticated)
{
if (HttpContext.Current.User.Identity is FormsIdentity)
{
FormsIdentity id = (FormsIdentity)HttpContext.Current.User.Identity;
FormsAuthenticationTicket ticket = id.Ticket;
string userData = ticket.UserData;
}
}
}

Any ideas on fixing this greatly appretiated!


.



Relevant Pages

  • Re: FormsAuthentication.Encrypt problem
    ... data before it gets ready for packing inside a cookie. ... expands the userData size in a way that it quickly reach this 4K ... This posting is provided "AS IS" with no warranties, and confers no rights. ...
    (microsoft.public.dotnet.framework.aspnet.security)
  • Re: Cookies Expiring due to different time zones.
    ... perfectly fine on my PC and many other PCs which have correct time. ... But, if I set date to some old date, user is simply unable to login. ... This makes sense as probably cookie timing is not matching. ... this.loginUser1.RememberMeSet, userData); ...
    (microsoft.public.dotnet.framework.aspnet)
  • Re: Cookie expiration issues
    ... public static bool LoginUser(int aPersonID, string userRole, bool ... // Save crucial data in userData ... System.DateTime.Now, // Time cookie issued ... persistentLogon, // Cookie persistence ...
    (microsoft.public.dotnet.framework.aspnet)
  • Re: HOW TO: Setting Up Forms Authentication
    ... What defines where the custom cookie is stored? ... string userData = String.Join; ... FormsAuthenticationTicket ticket = new FormsAuthenticationTicket( ...
    (microsoft.public.dotnet.framework.aspnet.security)
  • Cookies Expiring due to different time zones.
    ... perfectly fine on my PC and many other PCs which have correct time. ... But, if I set date to some old date, user is simply unable to login. ... This makes sense as probably cookie timing is not matching. ... this.loginUser1.RememberMeSet, userData); ...
    (microsoft.public.dotnet.framework.aspnet)