PHP account privilege , session or mysql check
<p>For a user with moderator privileges; When the user logs in do i query to check the user is a moderator, then set a session?  So on pages with moderator options , for example </p>

<pre><code>if($_SESSION['mod']==1) {
//moderator options
}  
</code></pre>

<p>Alternatively do i put a query on everypage and check if the user is flagged as a moderator? Then for moderator options, for example</p>

<pre><code>if($moderatorfound==1) {
//moderator options
}
</code></pre>

<p>Below, I currently set the username as a moderator in a cookie but as i am learning about PHP security this is unsafe;</p>

<pre><code>    if($moderator=='1') {
    setcookie('username[3]',$moderator,time()+(60*60*24*365));  
    }

 if($_COOKIE['username'][3]==1) {
    //moderator options
    }   
</code></pre>

<p>What is the secure way to do this? Example would help.</p>
