The following part of the code
& lt; script>
Window. Onbeforeunload=function (e) {
SetTimeout (function () {
SetTimeout (beforeloadResult, 50)
}, 50);
Return 'sure? ';
}
The function beforeloadResult () {
<? PHP
Set_time_limit (0);
The ignore_user_abort (true);
$servername="localhost";
$username="root";
$password="wgz52157";
$dbname="myFirstDB";
//create a connection
$conn=new mysqli ($servername, $username, $password, $dbname);
Mysqli_query ($conn, "DELETE FROM MyUsers WHERE id='$sessionid'");
mysqli_close($conn);
? & gt;;
Window. The location. Reload ();
}
</script>