title: Can't access session on other pages by redirecting using header function?
body: <p>Hi I am having trouble accessing session on other pages. I have done everything but can't solve it either. I start each page with session_start(). I have a form that gets username name and password and sends it to another page that saves this information in session array and redirects to the previous page but it seems like the session is not changed. It would be hard to help and understand without the code so here it is:</p>
  
  <p>In my sigin.php,</p>
  
  <pre><code> &lt;?php 
       session_start();
       $_SESSION['errorMessage']='0';
       include("header.html");
  
       if($_SESSION['loggedin']){
         print("&lt;div class='pageContent'&gt;
          &lt;h2&gt;Sign in&lt;/h2&gt;
          &lt;form method='POST' action='sign.php'&gt;
          &lt;input type='text' maxlength='20' name='username' placeholder='Username'/ required&gt;&lt;br/&gt;
          &lt;input type='text' maxlength='30' name='password' placeholder='Password'/ required&gt;&lt;br/&gt;
          &lt;input type='submit' name='submit' value='Sign in' style='padding:0.5em;margin-left:45%;font-family:cursive,helvetica,Arial; color:darkred;cursor:pointer;'/&gt;
          &lt;/form&gt;");
  
        if($_SESSION['errorMessage']){
           print("&lt;div style='font-family:inherit' color:red' margin:1em;'&gt;"
             . $_SESSION['errorMessage'] . "&lt;/div&gt;");
          }
  
       print("&lt;div style='font-family:inherit;padding- 
         bottom:1.5em;margin:1em;'&gt;
          Don't have an account? &lt;a href='' style='text- 
        decoration:none;'&gt;Click here&lt;/a&gt;
           to sign up.
           &lt;/div&gt;
         &lt;/div&gt;");
        }
        else{
            print("&lt;div class='pageContent'&gt;
               &lt;h2&gt;You are logged in.&lt;/h2&gt;
               &lt;/div&gt;
          ");
        }
  
       include("footer.html");
       ?&gt;
  </code></pre>
  
  <p>and the page that handles the form input:</p>
  
  <pre><code>&lt;?php
  session_start();
  if($_SESSION['username']==$_POST['username']&amp;&amp;$_SESSION['password']==$_POST['password'])
          {
              $_SESSION['loggedin']='true';
              $_SESSION['errorMessage']='';
          }
  else{
              $_SESSION['errprMessage']='The username and password combination is invalid!';
              $_SESSION['loggedin']='false';
  }
  header("Location:signin.php");
  exit();
  ?&gt;
  </code></pre>
  
  <p>Please help me as I can't find any help on internet about this. Thanks...</p>