lanandpercy
Wed 7 February 2007, 03:40 am GMT +0200
if one want a simpler check just using session ?
using the $_SESSION['logged_in'] variable and just checking it ?
session_start();
if (!$_SESSION['logged_in'])
{
header ("Location: login.php");
}
using the $_SESSION['logged_in'] variable and just checking it ?
session_start();
if (!$_SESSION['logged_in'])
{
header ("Location: login.php");
}
Hi nitrixud,
We have a working educational site, but you might not want to do this if you are a site dealing in money!
We successfully added a...
$_SESSION['access_level']
with just a couple mods.
You can see the these at:
http://www.webdigity.com/index.php/topic,5503.0.Adding+%24_SESSION%5B%27access_level%27%5D+to+the+class.html

We use this to show different educational levels (menus and pages) based on the access_level in the database.
We use:
Quote
if ($_SESSION['access_level'] > 0) {
echo 'logged in stuff' :
} else {
echo 'not logged in stuff' :
}
To test if a person is logged in...
Because our site builds, meaning each access_level may view its educational level and any level beneath it we can use a simple test too, like these...
Quote
if ($_SESSION['access_level'] > 1) {
echo 'Stuff for levels above 1' ;
}
if ($_SESSION['access_level'] > 2) {
echo 'Stuff for levels above 2' ;
}
And we put our admin page in a "hidden" location...
Quote
if ($_SESSION['access_level'] == 255) {
echo 'Stuff for Admin_level' ;
}
This works well but I would not use it for anything dealing with money or national security! :)
Likewise, if you modify the class, you do it at your own risk. We have asked Olaf to add this, and his answer seemed to be in agreement, but until he does, you will have to modify your class with each new release. That is what we do!
For us, this is a great little mod. Quick and easy to do.
PS: This little mod also adds the ability to declare additional
$_SESSION['anything_you_want'] VARS without having to worry about tearing them down at logout. For example, add them to an extension class!
PPS: If all you want is to test if a person is logged in or not, you could try this code... we use it to display a login box as well as the appropriate links for:
Quote
Register Here
Forgot Password
Change Profile
Logout
Quote
if (isset($_SESSION['user'])) {
echo 'logged in stuff' :
} else {
echo 'not logged in stuff' :
}