FileOne.php is housing a <form>
posting to FileTwo.php, which has roughly a 20s loading time.
FileOne.php is setting a cookie, setCookie('currentStep', 0)
, and I need FileTwo.php to update the cookie every time its own function updateStep()
is called. The function and cookie are executing and updating correctly, but even if call the function immediately after the initial <?php
at the top of my file, it still takes the full 20s for my cookie to update in the client.
FileTwo.php - Function
function updateStep() {
setcookie("currentStep", ++$_COOKIE['currentStep']);
}
I've tried using ob_start()
and ob_flush()
to force a JavaScript cookie update to the client, but it's also taking the full 20s.
FileTwo.php - Alternative Attempt
<?php
ob_start();
echo "<script>document.cookie = 'currentStep=" . ++$_COOKIE['currentStep']) . "'<script>";
ob_flush();
What I'm attempting to do is dynamically update a progress bar using the cookie as a marker for steps. I did find potential alternatives, but I'd still like to know if there's a way to update my cookie from FileTwo.php while it's being executed from the <form>
post.
Comments
Post a Comment