Hmmm, looks like you'd need something else maybe browser-side that would flag a disconnect more so than a connection.
Ex.
Say a person visits your site, this does all the stuff that says "Hey someone is connected". If they leave the page, or close the browser, nothing is there to say "They left the site". In my limited understanding of php, it is server side, so whatever they do on their end, unless they click a logout button, your site won't know. Possibly something like Javascript would work better, or something from the server that could check a connection at an interval.
Either way I'll be watching this post, in case a good idea does come up.