php - Give a name to a session and check if a session with that name exists -


i'm building website there 3 kinds of login pages different type of users (ex. customers , salesmen). there pages should accessible specified users. if tries enter specific page, script check whether person allowed so.

the way see it, should create different session names @ each login page , when somebody's trying access specific page, check whether it's right person in right place.

i know checking if session exists can done via

isset($_session) 

and found information session_name here: http://php.net/manual/en/function.session-name.php

but don't seem put 2 things together. suggest solution? i've been learning php 3 weeks, please go easy on me.

by registration set user permission 1 , 2 , save database along username , hashe pasword

| id | username |            password hash         | user level | | 1  |  user01  | t5ns4fdgn6sdn45d4t5zuk65fz6s4dt1 |      1     | | 2  |  user02  | e8tdzjui56jn4fgvh635csd6trz6ghr8 |      2     | 

by every login set user level $_session["userlevel"].

and @ pages want protect following (at cery begining of document):

function userlevel($level){   if($_session["userlevel"] == $level){     header("location: index.php");     exit;   } } 

and can sort users:

userlevel(1); // user 1 can access page userlevel(2); // user 2 can access page  

Comments

Popular posts from this blog

javascript - Jquery show_hide, what to add in order to make the page scroll to the bottom of the hidden field once button is clicked -

javascript - Highcharts multi-color line -

javascript - Enter key does not work in search box -