Re: Problem with Auth
| From: | Leonie \(phpgroup\) | Date: | Sun, 20 Mar 2005 05:40:18 +0000 |
| Subject: | Re: Problem with Auth | ||
| References: | 1 | Groups: | php.pear.general |
| Request: | Send a blank email to pear-general+get-18160@lists.php.net to get a copy of this message | ||
After much goggling I found this tutorial:
and mostly copied my function thus:
require_once 'Auth/Auth.php';
// Initialization of database related information
$params = array(
"dsn" => $dsn,
"table" => "auth",
"usernamecol" => "username",
"passwordcol" => "password"
);
$a = new Auth('DB', $params);
// Detection, if user is logged in. Otherwise the login form
// is being displayed.
$a->start();
if ($a->getAuth()) {
if($_GET[act] == "logout") {
// Log user out
$a->logout();
echo "You have been logged out!<br />\n";
echo "<a href=\"$PHP_SELF?act=login\">Login</a><br />\n";
} else {
// output the content of your site, that is only visible
// for users which have been authenticated successfully.
printf("Welcome user <b>%s</b>!<br />\n", $a->getUsername() );
echo "<a href=\"$PHP_SELF?act=logout\">Logout</a><br />\n";
}
} else {
// not authenticated
echo "<center>You are not authenticated.<br />\n";
echo "</center>\n";
exit();
}
So now I have the login stuff working with the database. Wonderful.
But now I'm being asked for authentification every page. Why isn't it saving the login in a session or something? How can I get this to work?
Leonie