1
我有一个'UI'设置来控制外观,用户可以更改设置,但是它涉及到更新cookie。c#更新Cookie,不强制用户登录
我似乎能够更新,但它强制用户再次进行身份验证,我如何更新cookie而无需让用户再次进行验证?
//We need to update the userToken as the menuOptionChanged
var usertoken2 = new UserToken(schedule.MinimisedMenuBool);
HttpCookie cookie = FormsAuthentication.GetAuthCookie(usertoken.UserName, false);
var ticket = FormsAuthentication.Decrypt(cookie.Value);
var newticket = new FormsAuthenticationTicket(ticket.Version,ticket.Name,ticket.IssueDate,ticket.Expiration,false,usertoken2.CalculateRawToken(),ticket.CookiePath);
// Encrypt the ticket and store it in the cookie
cookie.Value = FormsAuthentication.Encrypt(newticket);
System.Web.HttpContext.Current.Response.Cookies.Set(cookie);
好点,只是没有想到这一点。 – 2014-10-10 11:35:38