Jump to content

Clients browser's tab closed during run time


YigalB

Recommended Posts

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

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

  Quote

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

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.

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.