I´m building an app where a check will be made every x number of seconds to see if a user is not reachable in order to determine if the user is no longer online. The chance of that the user is not going to close the app before disconnecting from the network, sending an "I´m offline" message is high, so this is why. The users are in a mySQL database, and I know there´s an event that can be fired there. Unfortunately my current hosting plan does not allow me to do this, so I´m wondering if there´s any point in setting it up in php by:
Making an infinite loop inside which is checked every x number of seconds for recent activity of users who are marked as online. Users automatically ping the server frequently, which will then store latest time of ping.
I got the feeling that this is not a good approach, and can the running loop actually just be stopped by calling it with sending some if value = blahblah then exit loop command?