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

120
Views
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 answers
Answer question

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 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!