I'm asking for the best method to go down for creating a login system for my web application. This web application also has an android app I am developing and I have the same question for that login system.
My problem is I would like a status for each user to show whether the user is 'online' or 'offline', and I can't find much information on this topic/understand how it would be done. My C# web application currently uses .net Authentication and connects to SQLServer database for user credentials check to gain access to the app. But I'm unsure how I would be able to ensure a user is 'Online' once logged in and then subsequently 'Offline' if a user is not logged in? I also don't understand how it would work if a user's PC died or the user closes the web application window.
This is the same problem I have in android application, is there any methods that would provide this type of login 'status' for an android application?
Sorry If my English is not the best. Any help/suggestions would be greatly appreciated.
CodePudding user response:
Add the column as Bayram suggested.
Add another column "lastKeealive" that is a date. Update the column at fitting intervals in code and/or on user activity.
If the date is older than X the user is offline, and can be set to offline. "lastKeealive" could be updated.
Either implement in app code of a separate process that runs separately.
CodePudding user response:
You can show the user to be online when the mouse is active, and update database every 10 minutes, if the user is not active for 10 minutes it will automatically mark as away.