I basically have a php script connecting to a pdo:mysql database which executes some time-consuming loop.
All works fine, unless the query is still running on the server side, updating infinitly, even after browser closed. I have to kill the mysql proccess (sleep) to stop it.
That is only for complete transactions. Closing the browser or tab completely cancels that transaction with no goodbye. Its like hanging up the phone on someone.
That’s normal for a TCP/IP connection. When the server sends a packet and it reaches the client and if the connection has been closed by the client, it will send a packet back stating it.
“The STOP button discovery (and so script abortion) worked only in case script was outputing something. If script is just doing something like scripts or MySQL calls and does not output anything to the browser neither automatic termination not connection_aborted() check seems to work. More over you need both ob_flush() and flush() together with IO for it to work reliably as if no low level network send is attempted connection abort from client will not be discovered.”
Not necessarily… true is true only before user closes the browser
How did the looping php script running on the server find out the browser was closed?