I have a loop that does some actions, within the loop I have a session counter that increments. It takes around 10-15 minutes for this loop to finish so I would like to have some kind of progress bar that tells user how far its gone through the loop.
My AJAX Call suppose to retrieve the value of the session that I set inside the loop but it does not seem to work. I get undefined index error.
I read somewhere that session gets locked once its used by one script and until it finishes using it, does not unlock it. Is it possible to force unlock on session so my ajax script can retrieve the value of session?
Example:
Script 1 (Loop):
while(SOME CONDITION) {
//DO ACTIONS
$_SESSION['progress'] = $currProgress + 1;
}
Script 2 (AJAX Call Retrieve Session):
function getCurrentProgress() {
$progress = isset($_SESSION['progress']) ? $_SESSION['progress'] : 0;
echo json_encode(array('progress' => $progress));
}
JS AJAX (calls every 30 seconds) to the above script