I have a front end script that calls a PHP page via ajax. That PHP page can run for 20-30 seconds. During its run, it sets a $_SESSION
variable multiple times to indicate status/progress.
While it's running, I want to have an interval in JavaScript that calls another script via ajax that simply checks that $_SESSION
variable and returns its current value.
My question: will the second script see the updated value in the $_SESSION
even while the first script continues to run?
First Script
//We check session started...
//Start
$_SESSION[ "status" ] = "started";
//Some long function
doSomethingSlow();
//Progress
$_SESSION[ "status" ] = "did something";
//Some long function
doSomethingElseSlow();
//Done
$_SESSION[ "status" ] = "started";
Second Script
//We check session started...
//Return the status
return json_encode( array( "status" => $_SESSION[ "status" ] ) );