0

Say I have two PHP scripts. The first one looks like this:

<?php
session_name('zzz');
session_start();
sleep(10);

The second one looks like this:

<?php
session_name('zzz');

$start = microtime(true);
session_start();
$elapsed = microtime(true) - $start;

echo "took $elapsed seconds";

If I visit the first script with a browser and then visit the second script right after the second script will take 10 seconds to run just like the first script. If I visit the first script and hit stop 0.5 seconds into it's loading the second script will still take ~10 seconds to load.

So if "Stop" doesn't reliably stop time consuming PHP scripts (such that the second script in the above example returns it's output instantly) what will? I guess I could do ps aux | grep apache2 on the CLI and then kill every apache2 proc but then that might kill the webserver all together and idk that I'd want to do that.

Any ideas?

neubert
  • 15,947
  • 24
  • 120
  • 212
  • 1
    possible duplicate of [PHP & Sessions: Is there any way to disable PHP session locking?](http://stackoverflow.com/questions/3371474/php-sessions-is-there-any-way-to-disable-php-session-locking) – AD7six Mar 20 '15 at 15:46
  • "Stop" only stops the browser trying to load the page. The php script will continue to run until it attempts to send something to the client and notices it's not there (unless [ignore_user_abort](http://php.net/manual/en/function.ignore-user-abort.php) is set - in which case it'll keep going until the end of whatever processing it's trying to do). – AD7six Mar 20 '15 at 15:48

0 Answers0