onlyican Posted August 29, 2006 Share Posted August 29, 2006 heyI have been coding for over 24 hours now, I needed a lil breakSo, my version of a break is to research some things,I was checking the php.net site, for functions that might be useful, or might do the same as some functions I have madeI came accrossconnection_aborted();Theres not much information on thisThe only info it says is "Will return true if the clients has disconnected"Does that mean, I can use this to check if a logged in user has disconnectedMeaning I can log them outIs the Disconnected from Closing the Window or something else?http://www.php.net/manual/en/function.connection-aborted.phpAnyone know anything about this function? Quote Link to comment https://forums.phpfreaks.com/topic/19007-info-on-connection_aborted/ Share on other sites More sharing options...
wildteen88 Posted August 29, 2006 Share Posted August 29, 2006 [url=http://www.php.net/manual/en/features.connection-handling.php]This[/url] has more indepth info on what it is used for. Quote Link to comment https://forums.phpfreaks.com/topic/19007-info-on-connection_aborted/#findComment-82165 Share on other sites More sharing options...
Jenk Posted August 29, 2006 Share Posted August 29, 2006 It's not used often because there isn't many scenarios to use it in.PHP won't suddenly wake up and do something when the user disconnects, that function can only be used with in the process of a very long, or infinite loop, and that's it.As the (not very good) example shows from the user notes on the php page:[code]<?phpwhile (!connection_aborted()) { echo "New line!<br />\n"; flush();}?>[/code]Because of the way PHP works with it's output buffer, you have to invoke the flush() function else the user will not see any output until all operations have ceased. (Which they won't see because the only way to cease the operation is to disconnect..)This function is primarily to allow developers to cut down on the amount of resources used by PHP on some operations. Other wise the above would infinitley loop hogging all your servers resources. Quote Link to comment https://forums.phpfreaks.com/topic/19007-info-on-connection_aborted/#findComment-82170 Share on other sites More sharing options...
onlyican Posted August 29, 2006 Author Share Posted August 29, 2006 ok cheersI thought it would run a script when the user closes a window.I was thinking excellent way of logging users out, to check who is onlineI stick to my old wayCheers hombres (and ladies if any) Quote Link to comment https://forums.phpfreaks.com/topic/19007-info-on-connection_aborted/#findComment-82191 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.