How can I add an expiration date to the authentication cookies?
I can set the session expiration for each AuthProvider but I can’t find a way to set the expiration date for the auth cookies.
plugins.Add(new AuthFeature(() => new UserAuthSession(),
new IAuthProvider[]
{
new BasicAuthProvider() {SessionExpiry = new TimeSpan(1,0,0,0)},
new CredentialsAuthProvider() {SessionExpiry = new TimeSpan(1,0,0,0)},
}, htmlRedirect: “/login”));
Thanks
You can either set the static property:
SessionFeature.DefaultSessionExpiry = TimeSpan.FromDays(7 * 2);
Or register an instance property:
Plugins.Add(new SessionFeature { SessionExpiry = TimeSpan.FromDays(7 * 2) });
These both need to be done before registering the AuthFeature, which otherwise would register the SessionFeature with the default expiry of 14 days.