-1

I'm having a problem, I'm doing a system in php and should show how many users are online and how many are offline.

so I did a column "online type int" 0 = offline, 1 = online.

when the user logs into the system switches to 1, and when you click logout switches to 0, the problem is as the user closes the tab or turn off your computer, you can not change to 0.

how you can do that?

false
  • 10,264
  • 13
  • 101
  • 209
Offboard
  • 27
  • 5
  • Does this answer your question? [Whats the easiest way to determine if a user is online? (PHP/MYSQL)](https://stackoverflow.com/questions/1051895/whats-the-easiest-way-to-determine-if-a-user-is-online-php-mysql) – gre_gor Feb 25 '22 at 11:57

1 Answers1

0

You may have to do session handling. When user logs in, for that session it should be 1. If user logs in from other location, for that session you may have to keep 1 in memory, when user closes the window, session gets over. At that time you have to delete that session from memory. When there is no session in memory, user is logged out.

Mayur Shah
  • 39
  • 8