title: Show content only if logged in
body: <p>Hello I have a question. I have set up my login system with cookies and it works. But I wonder is there a more clean version of doing this.</p>
  
  <pre><code>&lt;?
  include('../config/db_config.php');
  
  $username = $_COOKIE['user'];
  $password = $_COOKIE['pass'];
  
  $result = mysql_query("SELECT * FROM users WHERE isadmin = 1");
  
  while($row = mysql_fetch_array($result))
  {
      if($username == $row['username'] &amp;&amp; $password == $row['password'])
      {
          //User entered correct username and password
          echo("ALLOW");
      }
      else
      {
          //User entered incorrect username and password
          echo("DENY");
      }
  }
  ?&gt;
  </code></pre>
  
  <p>You see I want all my content to be shown ONLY if I am logged in as admin. So what, now only way of doing this would be ECHO'ing out my HTML/PHP/Javascript instead of echoing ALLOW because if I just include("somepage.php") there that page would still be avialable for usage without logging in, and even if I do same check there I still would be ECHO'ing out everything.</p>