Search code examples
phpmysqlxmppuser-presence

Only two people on a certain page at a time?


I'm not really sure how I would implement this along with a fair amount of security. I want to be able to know if someone or two people are on based on a mysql row. These two people are totally anonymous. I do have an xmpp server set up but I'm not sure how that would integrate into the mysql and I already have a separate login system for it. Server side is done with PHP

Edit: I want to ONLY allow two people on a certain page and that is it. But, if they leave the page I need to determine if they have left.


Solution

  • The issue is that if somebody closes their browser you have no way of being notified that they have left the page.

    What you could do is have an AJAX request on the page, so that every 10-15 seconds it sends a request to the server containing a session id. Log the timestamp and the session id in a table, and you can then query the database to see what requests have been made in the last 15 seconds