Basically all you need to do is register variables as session when they login
So lets say, if you had the information in a database you'd query the database to get the username/passwords, then match it against what they put in. If it is correct then just do something like this
PHP Code:
$_SESSION['USERNAME'] = $sqlrow['USERNAME'];
$_SESSION['PASSWORD'] = $sqlrow['PASSWORD'];
$_SESSION['USERID'] = $sqlrow['USERID'];
And include any other variables that you want to check through every page.
Then in each page that requires login just have this
PHP Code:
if (!session_is_registered("USERID"))
{
session_destroy();
header("Location: login.php");
}
And when you want to check the variables you can just use
PHP Code:
$_SESSION['VAR']
Also, to logout just use session_destroy(); and it dumps all session variables.
Hope this is of any help.
|