我正在使用 ASP.NET Web 应用程序和 FormsAuthenticationTicket。在 FormsAuthenticationTicket 中,我保存了用户名,但我也需要用户的 ID。我试图将 ID 保存在 Session 中,但它并不总是有效。
FormsAuthenticationTicket ticket = new FormsAuthenticationTicket(1, t.FullName, DateTime.Now,
DateTime.Now.AddMinutes(2880), CheckBox1.Checked, t.Credential, FormsAuthentication.FormsCookiePath);
string hash = FormsAuthentication.Encrypt(ticket);
HttpCookie cookie = new HttpCookie(FormsAuthentication.FormsCookieName, hash);
有没有办法以更好的方式保存 ID?