Using ajax, I made it possible so that a user gets logout after 10 seconds of staying on the same page. Keep in mind that the 10 seconds is just for testing purposes. However, if the user closes their browser before the 10 seconds are up, they do not get log out. I thought about logging them out when they exit their browser, but I have yet to figure out how, and even if I do, what does exiting their browser entails? Does it count if they just close a tab while there are other tabs open? What if they have 2,3 or more browsers open at the same time? How do I determine that all those open browsers are exited before logging them out?
test1.php
<?php
include('ajax.php');
sleep(10);
?>
<html>
<body onload = "ajax('test2.php','output',10000)">
<div id="output" />
</body>
</html>
test2.php
<?php
include('connect.php');
include('functions.php');
ud("login = 'false'/userLogin/where username = '$username'");
?>