I am trying to implement remember me feature into my MVC application and I'd like to accomplish it by using MVC Identity. Normally the session expires in one hour, however, whenever the user checks remember be checkbox, the expiration time would change to one week. I'm using cookie authentication. What is the correct way to approach this problem?
Asked
Active
Viewed 2,479 times
2
-
What kind of authentication you are using?? – Power Star Aug 01 '17 at 07:03
-
Check [this](https://stackoverflow.com/questions/5619791/implementing-remember-me-feature-in-asp-net-mvc?noredirect=1&lq=1) one. it will help you. – Lifewithsun Aug 01 '17 at 07:03
-
I'm using cookie authentication – jElliot Aug 01 '17 at 07:04
-
Membership right?? Claim based?? – Power Star Aug 01 '17 at 07:06
-
Yes, correct, membership – jElliot Aug 01 '17 at 07:10
1 Answers
3
You just need to set IsPersistent to true to accomplish this when you sign in the user identity (you would want to also add some kind of remember me checkbox for the external flow probably as well)
If somebody checked the check box then IsPersisten should be true otherwise false.
AuthenticationManager.SignIn(new AuthenticationProperties { IsPersistent = <rememberMe> }, <userIdentity>);

Power Star
- 1,724
- 2
- 13
- 25