title: store error message in session and display on another page
body: <p>there is a scenario that i have in my hand at present.I have 2 pages <code>index.php and code.php.</code> </p>
  
  <p>the user first goes to index.php page and then is redirected to code.php page and back to index.php page.  </p>
  
  <p>in case some error occurs in code.php page, i need to display that error on index.php page when it gets redirected back to index page.</p>
  
  <p>i stored the error message in session like this and then redirected the page bsck to index.php page</p>
  
  <pre><code>$_SESSION["errormsg"]='please try again';
  header("Location: index.php");
  </code></pre>
  
  <p>but if i echo this session message in index.php page it gets displayed evertime when the page gets loaded, however i want only once when the index page comes after the code.php page. can anyone tell how it can be done</p>