0

I search this site and google, but didn't find anything that helped. I have a program that creates a session when a user is logged in. My database sets the user as online until the user click on exit button. Then the user is set to offline in the database offline. This is so a user can login in one place only. The trouble is when the user doesn't click the exit button, but closes the browser or tab or when the computer turned off. When this happens the user is still set as online in the database and can not login again. I then have to use the admin area to manually exit the user.

How can I know on server side if the user is online or when thethe user closes the browser or has turned off their pc?

I know about the onbeforeunload or onunload javascript but don't think it can help because I must close session and set the database user is offline which the time to do this I think is so low.

  • 1
    PHP is server-side and has no idea about what is happening on the client. – Jay Blanchard Nov 07 '16 at 18:43
  • Furthermore it's none of your business to surveil anyones power usage. – mario Nov 07 '16 at 18:44
  • My site tracks online status through the "polling notifications" process. If you have anything like that, just use it to mark the user as "I'm still here", and if it's been too long since such a ping was received, mark them offline. Easy. – Niet the Dark Absol Nov 07 '16 at 18:52

0 Answers0