Session Management
Session Management¶
The Session Management feature allows you to prevent concurrent login and manage user sessions.
Prevent concurrent login¶
There is a setting in the identity section to prevent concurrent login. It has three options:
-
DisabledNo restriction on concurrent login. This is the default.
-
LogoutFromSameTypeDevicesOnly one session of the same type can exist.
Same typemeans we can restrict single login with a browser, but we may still can login with a mobile application without affecting the browser session. So, for each device type, we may allow a single login. -
LogoutFromAllDevicesAll other sessions will be logged out when a new session is created.

Manage user sessions¶
You can view and manage user sessions on the Users page of the Identity module.

Once you revoke a session, the user will be logged out.
IdentitySessionCleanupBackgroundWorker¶
The IdentitySessionCleanupBackgroundWorker is a background worker that will remove the sessions that have not been active in the past.
IdentitySessionCleanupOptions¶
IsCleanupEnabled: Default value istrue.CleanupPeriod: Default value is 1 hour.InactiveTimeSpan: Default value is30days.
How it works¶
This feature depends on the Dynamic Claims feature of the ABP framework. Here is how it works:
- The
IdentitySessionClaimsPrincipalContributorwill generate a random GUID as asessionidto add theClaimsPrincipal, This usually happens when logging in to get the user's claims. - The
OnSignedInevent ofIdentityandProcessSignInevent ofOpenIddictwill get thissessionidand store it in the database (IdentitySessiontable). - The
Dynamic Claimssystem'sIdentitySessionDynamicClaimsPrincipalContributorwill ensure thesessionidexists or signs out. - The
IdentitySessionCheckerwill check thesessionidthat exists and update theLastAccessedandIpAddressto the cache. - The
IdentitySessionManageris used to get one or a list of sessions and update theLastAccessedandIpAddressfrom the cache to the database. - The module will remove the session when logging out.
- The
IdentitySessionCleanupBackgroundWorkerwill remove the inactive sessions. - Once a new session has been created, we will remove the other sessions based on the
PreventConcurrentLoginsetting. - The
IdentitySessionManageris used to manage/maintain the sessions. Please use this class instead of directly using the repository. - The
UpdateSessionAfterCacheHit(10 times by default)property ofIdentitySessionCheckerOptionsis used to configure theIdentitySessionCheckerthat will update session in the database when cache hits reach this value. This is to reduce the database update frequency and improve performance.