0
我正在使用owin cookie身份驗證來保持用戶登錄。但我注意到cookie從客戶端瀏覽器中消失而未過期。登錄cookie在到期前消失
var identity = new ClaimsIdentity(DefaultAuthenticationTypes.ApplicationCookie);
var properties = new AuthenticationProperties() {
IssuedUtc = DateTime.UtcNow,
ExpiresUtc = DateTime.UtcNow.Add(Startup.CookieAuthenticationOptions.ExpireTimeSpan),
IsPersistent = true
};
HttpContext.Current.GetOwinContext().Authentication.SignIn(properties, identity);
啓動:
public class Startup {
public void Configuration(IAppBuilder app) {
CultureInfo.DefaultThreadCurrentCulture = CultureInfo.InvariantCulture;
GlobalHost.Configuration.DefaultMessageBufferSize = 100;
ConfigureCookie(app);
app.MapSignalR();
}
public static CookieAuthenticationOptions CookieAuthenticationOptions { get; private set; }
public void ConfigureCookie(IAppBuilder app) {
CookieAuthenticationOptions = new CookieAuthenticationOptions() {
ExpireTimeSpan = TimeSpan.FromDays(7),
CookieSecure = CookieSecureOption.SameAsRequest,
AuthenticationType = DefaultAuthenticationTypes.ApplicationCookie,
CookieName = "TokenHandler"
};
app.UseCookieAuthentication(CookieAuthenticationOptions);
}
}
沒有人有任何線索?我並不是百分之百地確信這一點,但那是我得到的感覺,因爲我現在需要更多地簽名。是否有可能新版本的網站可能導致這種情況?