title: How can I access my session variable in a different page with php?
body: <p>everyone I started the session variable at the top of the login.php page. the session is then set and I call the second page using the include statement.  I tested with an if statement and it seemed to pass ok.  then I try to echo the contents of the variable in the newly displayed page. The page displays meaning that it passes the if block but the contents of the session variable does not show.  It's as if the session variable has gone out of scope.  How can I access my session variable in a different page. </p>
  
  <pre><code> &lt;?php
   session_start();
   $username = "";
  
   if (isset($_POST['submit']))
       {
       $username = $_POST["username"];
       $password = $_POST["password"];
       $_SESSION["username"] = $found_admin["username"];
       if (isset($_SESSION["username"]));
       {
       redirect_to("index.php");
       }
        else
      {
      $_SESSION["message"] = "Username/password not found.";
      }
      }
  
   ?&gt;
  
  
   &lt;?php include("login.html"); ?&gt;
  </code></pre>
  
  <p>Here's the html page that's called by my php file:</p>
  
  <pre><code> &lt;!doctype html&gt;
  
   &lt;head&gt;
  
   &lt;/head&gt;
   &lt;body&gt;
   &lt;?php
  
   echo $_SESSION["username"];
   $loggenOnUser=$_SESSION["username"];
   ?&gt;
  &lt;div class="gridContainer clearfix"&gt;
      &lt;div id="div1" class="fluid"&gt;
  This page is being called by my login.php file.&lt;/div&gt;&lt;div id="LoggedInUser" class="fluid "&gt;Hi.  I'm &lt;?php $loggenOnUser?&gt; &lt;/div&gt;
        &lt;img id="homeImage"  src="images/home.gif" /&gt; &lt;/div&gt;
  &lt;/div&gt;
   &lt;/body&gt;
   &lt;/html&gt;
  </code></pre>
  
  <p>Can't seem to get why I can't get access to the session variable on another page. Any help would be greatly appreciated.  Thanks!</p>