How to use PEAR::Auth
| From: | Lassiege Hugo | Date: | Thu, 03 Feb 2005 15:00:11 +0000 |
| Subject: | How to use PEAR::Auth | ||
| Groups: | php.pear.general | ||
| Request: | Send a blank email to pear-general+get-17359@lists.php.net to get a copy of this message | ||
<mailto:pear-general@lists.php.net>
I try to replace my old authentification system by PEAR::Auth.
I had a login page (login.php) with a form (login, password ...). I used Session to keep data.
After that, on the top of each page I had
$admin_row = checkUser();
checkAdminData ($admin_row);
This two functions get informations in session and compare it to database. (I simplify and
didn't give the code because it's not very useful)
Now, I try to follow Auth Example.
I change my login page as described in the PEAR manual. I create a login function and use Auth
function (like in the manual):
$dsn = "mysql://user:password@localhost/database";
$a = new Auth("DB", $dsn, "loginFunction");
$a->start();
if ($a->checkAuth())
{
header("location:".INDEX."?page=adminstat");
}
But I didn't find in the manual what's the equivalent of my two functions in the header of
my others page that needs authentification. I suppose I don't have to recreate a Auth object,
so, how does it works ? (it's quite difficult to find example on google).