Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

MVC 5 Identity Automatic Logout

How do I implement an Automatic Logout Timer.

So basically if the user is inactive for x minutes their session is ended?

I have tried:

<system.web> 
   <sessionState timeout="1"/>
</system.web>

But it doesn't seem to work.

Here is code that is in my startup:

public void ConfigureAuth(IAppBuilder app)
{
  // Enable the application to use a cookie to store information for the signed in user
  app.UseCookieAuthentication(new CookieAuthenticationOptions
  {
      AuthenticationType = DefaultAuthenticationTypes.ApplicationCookie,
      LoginPath = new PathString("/Account/Login")
   });
 }

Which says that I am using cookie Authentication. So i dono what that entails if I can do it or not.

like image 489
Zapnologica Avatar asked Feb 06 '14 13:02

Zapnologica


1 Answers

Its a property in the App_Start\Startup.Auth.cs file:

  app.UseCookieAuthentication(new CookieAuthenticationOptions
  {
      ExpireTimeSpan = TimeSpan.FromMinutes(5),
      AuthenticationType = DefaultAuthenticationTypes.ApplicationCookie,
      LoginPath = new PathString("/Account/Login")
   });
like image 131
Hao Kung Avatar answered Nov 16 '22 09:11

Hao Kung