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?

Link to comment
Share on other sites

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?

Link to comment
Share on other sites

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?

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.