Most modern web based games (and platform too) are based on UDP socket connection, it's like a tunnel with the server, each of them has a socket id, so you can either interact or identify every connection.
Using sockets resolves all your troubles, it sends an action when users connects, disconects or emit's any call.
The easiest way to build a sockets app is with nodejs, you can build the sockets infrastructure in node and use your current php services from it.
I developed a morts that uses nodejs to connect clients and manage game rooms, python scripts to manage map objects and c++ "services" to do the hard calculations.
If you wanna stay with pure php you can build your own socket infrastructure, there are good documentation, just google "php socket".
Game rooms relative...In my online game i wrote an object called game that had all the code of a game and an array called Games that stores all the games, so, when two players enteres the lobby it runs something like this:
and with an eassy search function you can associate games to its unique GAME_UID, PLAYER_ID or whatever.
Good luck ;)