I am using some code that I "obtained" from another site, but it's not quite working as expected.
if (await _memberManager.ValidateCredentialsAsync(model.Email, model.Password))
{
var result = await _memberSignInManager.PasswordSignInAsync(model.Email, model.Password, false, true);
if (result.Succeeded)
{
return Redirect(model.RedirectUrl!);
}
}
There is also a "Remember me" checkbox on the form.
The login works, but a cookie is stored with a life of 1 year, even if the Remember Me option is not ticked.
The 3rd parameter in PasswordSignInAsync is "is Persistent" - shouldn't it not persist if that is set to false? And is that what the "Remember Me" option should affect?
Yes, but my question was - shouldn’t it NOT persist if that value is false?
Currently I am getting a cookie with a 1 year expiry date. And the login persists between browser sessions and I assume it shouldn’t (when the setting is false)?
Currently - running locally while developing in Visual Studio, if I log in, close the browser (stop the site), then restart it, the user is still logged in. I want them not to be if they didn't tick "Remember me"., which they aren't at the moment because I am always sending "false" to "isPersistent" (3rd param)
Member Login page with Remember Me
I am using some code that I "obtained" from another site, but it's not quite working as expected.
There is also a "Remember me" checkbox on the form.
The login works, but a cookie is stored with a life of 1 year, even if the Remember Me option is not ticked.
The 3rd parameter in PasswordSignInAsync is "is Persistent" - shouldn't it not persist if that is set to false? And is that what the "Remember Me" option should affect?
Finally, can I alter the lifespan of the cookie?
that is because you are allways setting the value to false
You need to set that to the value from your
model.RememberMe
Yes, but my question was - shouldn’t it NOT persist if that value is false?
Currently I am getting a cookie with a 1 year expiry date. And the login persists between browser sessions and I assume it shouldn’t (when the setting is false)?
Which version of Umbraco are you using? I am not seeing this behaviour
v13 - new site build.
Currently - running locally while developing in Visual Studio, if I log in, close the browser (stop the site), then restart it, the user is still logged in. I want them not to be if they didn't tick "Remember me"., which they aren't at the moment because I am always sending "false" to "isPersistent" (3rd param)
Are you referring to back-office users or frontend members?
Sorry, I should have been clearer - I am talking about Members. Signing in to a front-end Members area.
Try clearing cookies in case you have any old ones getting in the way. Have you made any other changes to the code?
This is not the behavior I am seeing.
is working on a reply...