I try to mark a value on session when the connection is aborted, but the php function connection_status() dosen`t work correctly! Here is code below:
1 WITHOUT while statements:
session_start();
ignore_user_abort(true);
ob_end_clean();
echo 'Testing'; //test if it has output to the browser
flush();
sleep(7);
echo "test";
flush();
if (connection_status() != CONNECTION_NORMAL){
$_SESSION['conn']='failed'; //never called
}
2 WITH while statements:
session_start();
ignore_user_abort(true);
ob_end_clean();
echo "Testing connection handling";
while (1) {
if (connection_status() != CONNECTION_NORMAL){
$_SESSION['conn']='failed'; //worked at some time
break;
}
sleep(1);
echo "test";
flush();
}
When I test with these code, I manually abord the connection before end of the code excution.
But first code do not work as Im excepted(do not mark assign 'failed' to the session) , and the second code works.
Why the first dosen
t work?!