Virab
June 25, 2016, 7:46pm
1
Hi Demis.
I have done it how you tell and have saved it with separately Id sasions:
You can’t sessions are stored against a random key. The only way to know inspect a Session is to access it individually.
But I wouldn’t recommend scanning all User Sessions like this, if you need all User Sessions I would register a OnAuthenticated Session or Auth Event and maintain a list of Sessions Ids for each user yourself.
I close sessions in this instructin by timeout, but during closing session doesn’t enter into Logout and I can’t clear a cache:
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)}, }, …
Can you tell how can I catch an event?
Sorry for mistakes
mythz
June 25, 2016, 10:00pm
2
The logout event is for when users explicitly logout.
There is no event you can catch and no callback is possible for Session Timeouts which happens when the Caching provider transparently expires the cache entries.
Jothay
July 29, 2016, 6:56pm
3
Would a timer based on the session expiration during the Authenticate method be roughly appropriate?
For instance, in my authenticate, I’m saving the session with a new SessionExpiry
authService.SaveSession(session, SessionExpiry);
I could set a timer to fire just before the expiration would occur and then call Logout. Any reason why that would fail?
mythz
July 29, 2016, 6:59pm
4
That’s very fragile, a Timer requires a background thread which you wouldn’t want to create for every session and wouldn’t work beyond App Domain restarts.