Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to persist the login information after closing Browser using asp.net Identity?

When using the ASP.NET Identity, I want to persist the login information as long as possible when the user logs in to my website, so the user doesn't need to login again when they reopened their Browser (just like github.com and stackoverflow.com). When I login to github, it persists my information for many days, so I don't need to login again every day. Are there any methods can that can implement this functionality using ASP.NET Identity?

like image 858
kinshines Avatar asked Dec 22 '15 02:12

kinshines


1 Answers

Just pass the appropriate value to the isPersistent argument of the SignIn methods:

SignInManager.PasswordSignInAsync("[email protected]", "password", isPersistent: true, shouldLockout: false);

or

SignInManager.SignInAsync(applicationUser, isPersistent: true, rememberBrowser: false);

The isPersistent argument is used to control if the user's authentication cookie should be persisted.

The rememberBrowser argument is used in case of Two Factor Authentication: a remembered browser can login directly with the password alone.

like image 113
galdin Avatar answered Oct 18 '22 04:10

galdin