D
dev648237923
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!
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!