title: Redirect not working with Header(Location ) and session variable
body: <p>1: i use register.php to sign up the clients,</p>
  
  <p>2: the data collected from the form is send to 1.php, it is saved in database</p>
  
  <p>3: after form data is saved in database, 1.php forwards selected form data (myValue) to register.php?myValue='abc'</p>
  
  <p>in 1.php, i am saving a session variable like this </p>
  
  <pre><code>@session_start();
  $_SESSION['color']='blue';
  </code></pre>
  
  <p>the code of register.php is </p>
  
  <pre><code> if (isset($_SESSION['color'])) {
              header('Location: http://mydomain.com/thankyou.php');
      }
   else {
  
  
  @session_start(); 
  some other stuff  that was initially use for signing up the clients
  </code></pre>
  
  <p>my logic is to check for session variable and to redirect it to some-other page</p>
  
  <blockquote>
    <p>when step 1 , step 2 and step 3 are complete, page should be
    redirected to thankyou.php</p>
  </blockquote>
  
  <p>currently, when step 1, step 2, step 3 are done, instead of opening thankyou.php, the following page is being opened </p>
  
  <pre><code>http://mydomain.com/register.php?myValue='abc'
  </code></pre>
  
  <p>however, if i re-open register.php or go back to step one (opening register.php), thankyou.php is displayed...</p>
  
  <p>can somebody guide me where i am doing the blunder? why redirection is not being successful although session variables are being created? </p>
  
  <p><strong>code Update</strong></p>
  
  <p>i tried the following code at the top of my register.php</p>
  
  <pre><code>@session_start();
  
  
     if (isset($_SESSION['color'])) {
              header('Location:http://mydomain.com/thankyou.php');
              exit;
      }
   else{
  remaining stuff
  </code></pre>
  
  <p>it occasionally do the trick, redirects to the page, while on occasion (greater in number), it fails in redirecting to thankyou.php,, also the code needs to delete complete history and cache to work (after doing so, still miss hits occurs..)</p>