Location: PHPKode > scripts > PHP Address book > php-address-book_v_1.01_eng/php-address-book_v_1.01_eng/classes/session.class.php
<?php
session_start();

class session{
    private $role;
    /*
     * initialize class and set the role
     */
    function __construct($database) {
        if(isset($_SESSION['userid'])){
            //init
            $id = $_SESSION['userid'];
            
            //check role
            $query = $database->query("SELECT * FROM `cal_users`  WHERE `id` = '$id'");
            while($row = mysql_fetch_assoc($query)){
                $this->role = $row['role'];
            }
        }
    }
    
    /*
     * get role of the user
     */
    function getRole(){
        return $this->role;
    }
}
?>
Return current item: PHP Address book