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

72
Views
PHP doesn't see a cookie unless I refresh the page again

I know there are other questions like this on here, but I've read through the answers and I'm still not finding a solution to my issue.

All of these scripts are on the same page, search-results.

It shows results in data-tables, and lets the user select records to save to a list, which they can then print. The IDs of the selected records are stored in a records cookie. I can see that this works.

There's a link at the bottom of the page that fires this JS function:

function resultsPage(){
    window.location = "/search-results/?printqueue=true";
}

As you can see, this is the same page, but with a different parameter. This tells the page to display their saved results.

On the initial load with ?printqueue=true PHP cannot read the cookie, even tho the page has refreshed. I have to refresh (or click the link) AGAIN before PHP picks up the cookie. Why?

I'm getting the cookie data like this:

if( $_GET['printqueue'] == 'true' && $_COOKIE['records'] !== 'undefined' ) {
    $posts_to_show = explode(',',$_COOKIE['records']);
}

If that's just because of the order of operations, that's cool, nothing to do about it then. But any clean ways to "double refresh" the page without adding an extra parameter and refreshing again if it's present? I'd really hate to do that...

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

I beleieve its becouse $_COOKIE['records'] is not set yet..

Try:

if( $_GET['printqueue'] == 'true' &&  isset($_COOKIE['records']) ) {
    // your code
}
about 4 years ago · Juan Pablo Isaza Report
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!