I have a table in the database where I store the user's session key, account ID and date. When the user logged in I insert it into this table and when logged out I delete it. But if a user is not logged out and his session is dropped. Data still remain. So I want to delete his data when the session is dropped. Is there any event that activates when the session is dropped?
I try to add the OnSessionDropped
function in the options at services.AddSession but .net core 6 is not supporting it.
CodePudding user response:
In .NET Core 6, there is no built-in event that is triggered when a session is dropped.
you can implement a background task which will regularly check the database for stale session records (records that have not been updated in a certain amount of time) and delete them.