PHP Session Variables - disappear and reappear
<p>I have a template file that contains all my header, footer and common information. It includes the appropriate content for the current page (two-step view pattern). </p>

<p>I am trying to set up a login system using PHP Session variables.  I can set the variable and sometimes they work but sometimes they disappear. Clicking on links will sometimes make them come back.  </p>

<p><a href="http://ejgejg.com/soccer/" rel="nofollow">My site</a> </p>

<p>Login with </p>

<p>username: test
password: test</p>

<p>There are <code>var_dumps</code> of <code>session_id</code> and <code>$_SESSION</code> at the top. </p>

<p>Click on Home. If the session variables disappear click on home (might take as many as 10 times) to see the session information come back. Click on the other navigation and sometimes the session info sticks around and sometimes it doesn't.</p>

<p>Here is the session code at the top of my template file.</p>

<pre><code>&lt;?php
session_start();

require './classes/DBInterface.php';
$db = new DBInterface();

if($_REQUEST['submit']  == 'Login') {
    $username=$_POST['username'];
    $password=$_POST['password'];

    echo '-- login -- '.$username;
    $rs = $db-&gt;verify($username,$password,"admin",0);
    $admin = $rs-&gt;current();
    if ($rs-&gt;valid()) {
     $_SESSION['username'] = $username;
    }
}

echo ' -- session id -- ';
var_dump(session_id());
echo ' -- session var -- ';
var_dump($_SESSION);
</code></pre>

<p>I am using PHP5.</p>
