title: Explanation of PHP sessions with roles please
body: <p>I have a MySQL database. In that database I have table called <code>users</code>. In users I have <code>username</code>, <code>password</code>, <code>role</code>. If the role is <code>0</code> then it's a <em>user</em>. If the role is <code>1</code> then it's <em>admin</em>. </p>
  
  <p>This is how the session set right now.</p>
  
  <pre><code>if($count==1){
          echo "true";
          $_SESSION['username'] = $user;
          $_SESSION['password'] = $pass;  
      }
      else {
          echo "Wrong";
      }
  </code></pre>
  
  <p>This is what I have at the top of the pages:</p>
  
  <pre><code> session_start();
  
    if(!isset($_SESSION['username'])){
      header("location:login.php");
    }
  </code></pre>
  
  <p>I am confused about how to check again the role though. For example, if it's role 1 = they get admin pages if role 0 - user. </p>
  
  <p>Currently, I have only 1 admin, and this is how I've been given them authorisation. </p>
  
  <p>But I am not sure if this is correct. I need explanations please. </p>
  
  <pre><code>if ( 'admin' == $_SESSION['username'] ) {
  
      include('admin.php');
  }
  else {
      include('user.php');
  }
  </code></pre>