You could make a javascript function which loads a PHP-Page in intervals.
Something like this:
create 3 files: file.js, onlinecheck.php and log.txt
file.js:
function tellTheServerThatIAmStillHere() {
$.post('onlinecheck.php', {onlineStatus: iAmStillHere}); /* Sends a post to the file onlinecheck.php with the parameter "onlineStatus: iAmStillHere" */
timer = window.setTimeout(tellTheServerThatIAmStillHere,8000); /* sends a new post every 8 seconds */
}
onlinecheck.php:
<?php
if(isset($_POST["onlineStatus"])) {
if($_POST["onlineStatus"] == "iAmStillHere") {
$fd = fopen("log.txt", "w");
fwrite($fd, date("[d.m.Y - H:i:s] ").$_SERVER['REMOTE_ADDR'].": He is still here"); //Puts out something like "[26.03.2014 - 13:57:33] 127.0.0.1: He is still here"
fclose($fd);
}
}
Now you could check in the logfile if the browser is still online, if that's what you meant.