Jump to content

Check Client Connection


Baez

Recommended Posts

I have this code to check if a user has disconnected. The loop keeps running, checking for a disconnection and when a user disconnects it should continue to the final function.

 

ignore_user_abort(true);
set_time_limit(0);

$i = 1;

while($i)
{
echo chr(0);

if(connection_aborted()) // check if connection is dead
{
	$i = 0;
}

sleep(10); // check again in 5 seconds
}

endScriptFunction();

 

However this does nothing. The while loop renders all links on the page completely useless and the end script function is never called even if the user closes the page. I've tried echoing a page break instead of null with the same result.

 

Can anyone provide some insight on a better way to do this? Thanks :)

Link to comment
https://forums.phpfreaks.com/topic/200054-check-client-connection/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.