mardi 4 août 2015

Role Based Session Expiring Duration in Asp.Net Identity

My Application is having 3 types of Asp.Net User Roles. Currently every user is having Cookie Expiration Time of 10 days. I am able to set this at Startup Class using this code:

  app.UseCookieAuthentication(new CookieAuthenticationOptions
            {
                AuthenticationType = DefaultAuthenticationTypes.ApplicationCookie,
                LoginPath = new PathString("/Home/Login"),
                ExpireTimeSpan = new TimeSpan(10, 1, 0, 0, 0),
                 SlidingExpiration=true,
}

The problem here is that this sliding expiring time is applied to all kind of users in the system. I am not able to figure out how can we set the expiring time of cookie based on the Role of the user who've just logged in.

Any help will be greatly appreciated.

Thanks

1 commentaire: