Authorizes and then authenticates a user without wasting time with a database request. Store any data as a cookie on the users computer and know that if they try to modify that data that will automatically be logged out of your system.
First you authorize the user:
require_once('UserAccessControl.php'); $UAC = UserAccessControl(); // Ensure user is valid against your login system $UAC->authorize($userdata_from_db);
Then whenever the user accesses a members only page:
require_once('UserAccessControl.php'); $UAC = UserAccessControl(); // login.php where the user is redirected to if they are not authorized $UAC->authenticate('login.php'); // Members only information
To end a users session:
require_once('UserAccessControl.php'); $UAC = UserAccessControl(); $UAC->deauthorize();
N.B. The users session will automatically timeout after a specified time of inacivity. (Default: 10 minutes)