I'm skeptical on whether or not this is allowed, because if it is then websites can get you stuck on a browser forever, but let me explain what I'm trying to do:
Users can log in, and they only have access to one single page. When logged on, it notes when logged in. When logged out, it notes when logged out. It forces log out if current time - logged in time is = 8 hours, 30 minutes (it's a bit more complex, but this is simplified for explanation). If the user decides to leave the page, then re-enter when it hits 8 hours 31 minutes, there's nothing done and they are able to 'game the system' so to speak.
I tried to do this:
$(window).unload(function() {
window.location="force-logout.php";
});
But nothing happened.
I've heard that even still methods like this don't work on all browsers, and even if they did I'm not sure if they would work on my issue just as the example i pasted did not work. And I tried to glean some info from this but nothing worked when I tried to repurpose it to my own issue.
Edit: removed extra info. Added attempted methods