Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

77
Vistas
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 Respuestas
Responde la pregunta

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 Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda