Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

78
Views
Updating Cookie from Form Post

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.

about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!