如何检测网页是否与php,javascript或jquery一起使用

I'm trying to figure out how one would detect whether a web-page is in use. I am building a kind of web-appliance which has an HTML5 RDP client type thing. I need to detect whether the page is currently in use, if possible a specific url including a GET variable. I have searched every variation that I can think of for doing this and have come up with the following, but none seem to work for me.

Pretty much my goal is to make a change in a mysql DB whenever a the page is active, then change it back when it's not.

  1. PHP sessions. This won't work for me because the session may still exist even if the user has left the specific page (I believe).
  2. Javascript window.onbeforeunload, however I see that this is pretty unreliable. Particularly if a user has security features enabled.
  3. I found some obscure referance to using php enviromental variables, but I wasn't sure how that would work, since it still wouldn't revert the variable or dismiss it when the page was closed.

Any suggestions are greatly appriciated!!!!