I'm trying, handle my program when client turn off browser or tab. while request php is not complete.
For example, i will save score to Database before browser or tab turn off
$i = 0;
$score = 0;
while($i++ < 100000){
$score +=2;
}
$sql = "UPDATE games SET score=$score WHERE uid=123";
$conn = new Mysqli(params);
$conn->query($sql);
if current $i is 1000, request is handling and client turn off browser or tab. Therefore, below command is not handle.
$sql = "UPDATE games SET score=$score WHERE uid=123";
$conn = new Mysqli(params);
$conn->query($sql);
How to immediate, i can save current score to Database.