PHP basic session usage
<p>This is basic php and I'm a newbie.</p>

<p>Here's my code on the first file:</p>

<pre><code>session_start();
$_SESSION['username'] = $username;
$_SESSION['password'] = $password;

header('Location: cms.php');
</code></pre>

<p>Here's the other one on another file:</p>

<pre><code>if (session_id() == '') {
    header('Location: login.php');
}
</code></pre>

<p>Basically, I created a session on the first code. What I'm trying to do in the next is determine if a session was created, if not, it will just be redirected to the login page. The issue here is that there's no session created at all, well that's what I thought since I tried displaying <code>session_id()</code> and it did not show anything.</p>

<p>So now what am I missing? I'm guessing it has something to do with the <code>header()</code> function. But nonetheless, I need help and would really appreciate some explanation and better code for this.</p>

<p>Thanks a lot!</p>
