2016-05-24 6 views
0

私はユーザーのサインインを維持するために、owin cookie認証を使用していますが、クッキーが期限切れになることなくクライアントブラウザから消えていることに気付きました。有効期限が切れる前にsigninのクッキーが消える

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); 
    } 
} 

誰もが任意の手掛かりを持っていますか?私はこれを確信しているわけではありませんが、もっとサインインする必要があるので、私が得た気持ちです。このウェブサイトの新しいリリースがこれを引き起こす可能性はありますか?

答えて

1

クッキーが正しく作成されていることを前提としています(ブラウザプロファイラーで有効期限が正しいことがわかります)。問題なくウェブサイトをナビゲートできることも確かです。 ...

テスト:ブラウザを閉じた後でクッキーを緩めるだけでチェックしてください。ブラウザの設定によっては、おそらく原因になる場合があります。いくつかの設定では、 "セッション"から "セッション"には保存しません。

関連する問題