0

I know that since HTTP is a stateless protocol, this cannot be detected directly. What I need to know is how to achieve this indirectly.

I am making a turn based game in PHP in which two users play over the internet. Need to detect disconnections of any user so that server can end the game and do end-of-the game processes.

I am tracking the last_activity_time of a user based on session, but don't know how to use this to detect a disconnection. Have seen some similar games use this, I can write my code myself once I get the logic. Any help would be much appreciated.

Ahmed Shefeer
  • 386
  • 2
  • 12
  • You could use javascript to let the connected user send a heartbeat. Or use JavaScript sockets. – Bart Friederichs Mar 04 '17 at 11:01
  • use javascript to call your server.php which will do the rest: http://stackoverflow.com/questions/7080269/javascript-before-leaving-the-page – LBA Mar 04 '17 at 11:02
  • Use jquery to call the php means server scripts through ajax . Then you can find the user disconnected or not through the jquery. – Pranav MS Mar 04 '17 at 11:12

0 Answers0