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

128
Vistas
how to show session variables only when appropriate?

I have a php1 page that transfers the user to a php2 page which sets the session variable and transfers the user back to the php1 page. e.g.(login form displaying an error message) Now when I wanted to display that session variable in php1 so I tried the following:

if(isset($_SESSION['messages'])){
  echo($_SESSION['messages']); 
}

the problem is that it will keep being displayed even if the user refreshes the page since the variable is still set. ps: I tried to use onload() and onunload() functions to unset it but it did not work, but I'm not sure if I did any mistakes.

about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

Remove the session variable after you show it.

if(isset($_SESSION['messages'])){
    echo($_SESSION['messages']); 
    unset($_SESSION['messages']);
}
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