This answer seems pretty comprehensive but my app is using ApplicationSignInManager
rather than AuthenticationManager
which the answer uses, so it doesn't really apply to my app.
I'm trying to track my user logins (this is a proprietary website to be used internally by the client). So the client basically wants the login to work like a time card so the boss can see when staff are coming in to the office.
This functionality means I can't rely on persistent logins per ASP.NET Identity default behavior since it doesn't allow me to control if/when the login cookie expires.
What I'd like to do is to expire the cookie at 4am every day regardless of when the login occurs.
For that reason, limiting the cookie's lifespan in configs doesn't really satisfy my requirement either.
Here's my login code - pretty much standard stuff. Per the first answer, I hoped I could embed the expiry of the cookie into the SignIn
method but since I'm using not using the AuthenticationManager
for sign in, there doesn't seem to be a way to do this with my current code.
var manager = Context.GetOwinContext().GetUserManager<UserManager>();
var signinManager = Context.GetOwinContext().GetUserManager<ApplicationSignInManager>();
// Note that this always persists the login cookie.
var result = signinManager.PasswordSignIn(Email.Text, Password.Text, true, shouldLockout: false);
// Evaluation of result below
If I need to change the way I'm doing logins here, that's fine; I'll just need some guidance on what changes to make (example code would be helpful).
Thanks in advance!