lanandpercy
Sat 6 January 2007, 07:04 am GMT +0100
We allow different users to see different parts of each page, and to see completely different pages using this...
Adding $_SESSION['access_level'] to the class
As I suggested in...
http://www.webdigity.com/index.php/topic,2288.0.access_user+%3A%3A+Future+functions+and+updates.html
(Reply 6 and Reply 8...)
I think it is a good idea to add $_SESSION['access_level'] to the class to make easy use of the access_level for things like selecting menu items and page content based on access_level.
I was able to do this with just a couple small modifications to the class... here they are...
Note: I have tested these but you should proceed at your own risk...
First I modify the function log_out in keeping with the current way of doing things on the PHP Manual for session_destroy. As noted on the above mentioned post (Reply 4). This would also allow extention classes to add $_SESSION Vars as they pleased.
Next I add the $_SESSION['access_level'] to the function set_user...
That's it! Now you can use $_SESSION['access_level'] to test with so you can include or exclude whatever you want in your PHP webpages based on the access_level!
I am hoping this will be added to future versions of the access_user_class! It is highly valuable to me!
Thanks Olaf - this is a great class and getting even better!
-Lan Tait
(With a name short enough to fit in a DOS file - how could I go wrong!)
Adding $_SESSION['access_level'] to the class
As I suggested in...
http://www.webdigity.com/index.php/topic,2288.0.access_user+%3A%3A+Future+functions+and+updates.html
(Reply 6 and Reply 8...)
I think it is a good idea to add $_SESSION['access_level'] to the class to make easy use of the access_level for things like selecting menu items and page content based on access_level.
I was able to do this with just a couple small modifications to the class... here they are...
Note: I have tested these but you should proceed at your own risk...
First I modify the function log_out in keeping with the current way of doing things on the PHP Manual for session_destroy. As noted on the above mentioned post (Reply 4). This would also allow extention classes to add $_SESSION Vars as they pleased.
Quote
function log_out() {
// unset($_SESSION['user']);
// unset($_SESSION['pw']);
// unset($_SESSION['logged_in']);
$_SESSION = array();
session_destroy(); // new in version 1.92
// unset($_SESSION['user']);
// unset($_SESSION['pw']);
// unset($_SESSION['logged_in']);
$_SESSION = array();
session_destroy(); // new in version 1.92
Next I add the $_SESSION['access_level'] to the function set_user...
Quote
function set_user() {
$_SESSION['user'] = $this->user;
$_SESSION['pw'] = $this->user_pw;
$_SESSION['access_level'] = $this->get_access_level();
$_SESSION['logged_in'] = time(); // to offer a time limited access (later)
$_SESSION['user'] = $this->user;
$_SESSION['pw'] = $this->user_pw;
$_SESSION['access_level'] = $this->get_access_level();
$_SESSION['logged_in'] = time(); // to offer a time limited access (later)
That's it! Now you can use $_SESSION['access_level'] to test with so you can include or exclude whatever you want in your PHP webpages based on the access_level!
I am hoping this will be added to future versions of the access_user_class! It is highly valuable to me!
Thanks Olaf - this is a great class and getting even better!
-Lan Tait
(With a name short enough to fit in a DOS file - how could I go wrong!)