title: Asp.net identity - Reset cookies and session on iis recycle (restart)
body: <p>I have implemented asp.net mvc with asp.net identity authentication.</p>
  
  <p>I have used cookie based authentication. After restart the IIS/stop and start the IIS for the my site, when i open my website, the user is automatically login to the system.</p>
  
  <p>The user cookie is not cleared and still valid for the user. How to force the user to log out after restart the iis?</p>
  
  <p>I have used default sample from the website.
  <a href="http://www.nuget.org/packages/Microsoft.AspNet.Identity.Samples" rel="noreferrer">http://www.nuget.org/packages/Microsoft.AspNet.Identity.Samples</a></p>
  
  <p><a href="https://i.stack.imgur.com/ReoyZ.png" rel="noreferrer"><img src="https://i.stack.imgur.com/ReoyZ.png" alt="enter image description here"></a></p>
  
  <pre><code>app.UseCookieAuthentication(new CookieAuthenticationOptions
              {
                  AuthenticationType = DefaultAuthenticationTypes.ApplicationCookie,
                  LoginPath = new PathString("/Account/Login"),
                  Provider = new CookieAuthenticationProvider
                  {
                      // Enables the application to validate the security stamp when the user logs in.
                      // This is a security feature which is used when you change a password or add an external login to your account.  
                      OnValidateIdentity = SecurityStampValidator.OnValidateIdentity&lt;ApplicationUserManager, ApplicationUser&gt;(
                          validateInterval: TimeSpan.FromMinutes(30),
                          regenerateIdentity: (manager, user) =&gt; user.GenerateUserIdentityAsync(manager))
                  }
              });
  </code></pre>