YigalB Posted January 29, 2012 Share Posted January 29, 2012 I made a bug which caused endless loop and endless printing. When I noticed that, I closed the browsers tab, fixed the bug, open a new tab and re-run. I was assuming the server would start from the beginning, but instead I noticed that some variables were active and the program continued from where it stopped. How can I make the program to stop when the client tab is terminated? Quote Link to comment https://forums.phpfreaks.com/topic/255971-clients-browsers-tab-closed-during-run-time/ Share on other sites More sharing options...
SergeiSS Posted January 29, 2012 Share Posted January 29, 2012 How can I make the program to stop when the client tab is terminated? It depends on 'ignore_user_abort' setting in php.ini. If it's set to TRUE your script would work until processing is finished. If set to FALSE processing is terminated. You may change default behavior via function ignore_user_abort() http://www.php.net/manual/en/function.ignore-user-abort.php In your case when you noticed that "the program continued from where it stopped"... Maybe your browser took it from the cash? Quote Link to comment https://forums.phpfreaks.com/topic/255971-clients-browsers-tab-closed-during-run-time/#findComment-1312152 Share on other sites More sharing options...
YigalB Posted January 29, 2012 Author Share Posted January 29, 2012 How can I make the program to stop when the client tab is terminated? It depends on 'ignore_user_abort' setting in php.ini. If it's set to TRUE your script would work until processing is finished. If set to FALSE processing is terminated. You may change default behavior via function ignore_user_abort() http://www.php.net/manual/en/function.ignore-user-abort.php In your case when you noticed that "the program continued from where it stopped"... Maybe your browser took it from the cash? It could be the browser took it from the cache. How can I prevent that? Also, i just added a "die" statement in my code, and was hoping that after that, if I refreshed the browser window, it would go back to the beginning. The browser actually continued executing the code. Is it again because of the cache? Quote Link to comment https://forums.phpfreaks.com/topic/255971-clients-browsers-tab-closed-during-run-time/#findComment-1312222 Share on other sites More sharing options...
SergeiSS Posted January 29, 2012 Share Posted January 29, 2012 The browser actually continued executing the code. Is it again because of the cache? Not sure It could be that some information is stored in a session in order to allow such behavior. It's up to you - check your code. Or show it here, we can check it together. Otherwise it's impossible to give you correct answer. Quote Link to comment https://forums.phpfreaks.com/topic/255971-clients-browsers-tab-closed-during-run-time/#findComment-1312249 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.