How to configure different ExpireTimeSpan for persistent and non-persistent cookies in ASP .Net Identity Core -


i have sign-in page remember me option. want configure remember me cookie expiry quite longer, 1 month.

i use cookieauthenticationoptions.expiretimespan property doesn't work "only" rememberme option.

i want user signed in few minutes, 30 minutes after sign-in, in current browsing session (if user didn't select rememberme option). in case use expiretimespan = timespan.fromminutes(30).

is there way configure "remembermeduration" configure 2 different settings when rememberme selected , when not selected? - out of box (at least not creating whole new middleware such small feature)

absolute expiry can used implement remember me (say 30 days) feature. when using identity, set expiresutc during signinasync after password check.

var au = new applicationuser() { email = model.email }; var r1 = await _usermanager.checkpasswordasync(au, model.password); if (r1) {     await _signinmanager.signinasync(au, new authenticationproperties() { expiresutc = datetime.utcnow.adddays(30) }); } 

if cookie middleware without identity used set expiresutc after customized password check successful.

from docs:

await httpcontext.authentication.signinasync(     "mycookiemiddlewareinstance",     principal,     new authenticationproperties     {         expiresutc = datetime.utcnow.adddays(30)     }); 

ispersistent , expiresutc mutually exclusive


Comments

Popular posts from this blog

mysql - Dreamhost PyCharm Django Python 3 Launching a Site -

java - Sending SMS with SMSLib and Web Services -

java - How to resolve The method toString() in the type Object is not applicable for the arguments (InputStream) -