0
I am trying to create a code for the user to close the browser, logout to run.
This is my Logout file.
session_start();
$_SESSION = array();
session_destroy();
header("Location:index.html");
I tried to use an onunload (below) to force the logout after the user leaves the page.
<body onunload="logout.php">
This way did not work, so I tried this way (below) and also did not work
<script>
function logout(){
window.location.href ='logout.php';
}
</script>
<body onunload="logout();">
Take a look at all the comments and the answer to this question and see if it helps you: https://answall.com/questions/430234/onbeforeunload-no-google-chrome-alguma-solu%C3%a7ao/430238#430238
– Benilson