Working with PHP Sessions
<p>I just developed a user login system and want to create different sessions for different users.</p>

<p>How do I write a code in PHP so that it starts a session and if the username entered is "a", it redirects to a different page and if the username is "b", it redirects to a different page.</p>

<h3>Update:</h3>

<p>I used this</p>

<pre><code>session_start();

switch ($_SESSION['username']) {
    case 'a':
        // $_SESSION['username'] is 'a'
        // redirect to file1.php
        header('Location: file1.php');
        die();
        break;
    case 'b':
        // $_SESSION['username'] is 'b'
        // redirect to file2.php
        header('Location: file2.php');
        die();
        break;
    default:
        // $_SESSION['username'] is neither a, nor b, or is not set at all
        // redirect to default.php
        header('Location: default.php');
        die();
        break;
}
</code></pre>

<p>but no matter what username I enter, it is taking me to file1.php</p>
