Auth_HTTP: problems with logout()
| From: | daniel dot garcia at assertio dot es | Date: | Thu, 03 Apr 2003 14:15:25 +0000 |
| Subject: | Auth_HTTP: problems with logout() | ||
| Groups: | php.pear.general | ||
| Request: | Send a blank email to pear-general+get-4625@lists.php.net to get a copy of this message | ||
Hi,
I cannot make the logout method work. I do the following:
1. I'm presented with the log in screen and I log in successfully
2. I log out
3. I try to log in again (hoping to see the log in screen again)
4. I'm not presented with the log in screen and I'm logged in
Here is some sample code:
$your_options = array(<your_options>);
require "Auth_HTTP/Auth_HTTP.php";
$user = new Auth_HTTP("DB", $your_options);
$user->start();
if ($user->getAuth()) {
if (isset($_GET['logout']) && $_GET['logout'] == 1) {
$user->logout();
echo "Disconnected<br>";
echo "<a href=" . $_SERVER["PHP_SELF"] .
">Connect</a>";
} else {
echo "Connected<br>";
echo "<a href=" . $_SERVER["PHP_SELF"] .
"?logout=1>Disconnect</a>";
}
} else {
echo "Not Authorized<br>";
}
I tried using Auth instead, and it worked fine:
$your_options = array(<your_options>);
require "Auth/Auth.php";
$user = new Auth("DB", $your_options);
$user->start();
if ($user->getAuth()) {
if (isset($_GET['logout']) && $_GET['logout'] == 1) {
$user->logout();
echo "Disconnected<br>";
echo "<a href=" . $_SERVER["PHP_SELF"] .
">Connect</a>";
} else {
echo "Connected<br>";
echo "<a href=" . $_SERVER["PHP_SELF"] .
"?logout=1>Disconnect</a>";
}
} else {
echo "Not Authorized<br>";
}
I tried overiding the logout method implementing it in Auth_HTTP as
follows:
function logout()
{
if (!empty($this->logoutCallback)) {
call_user_func($this->logoutCallback,$this->username);
}
$this->username = "";
$this->password = "";
$session = &$this->_importGlobalVariable("session");
$session['auth'] = array();
if (isset($_SESSION)) {
unset($session['auth']);
} else {
session_unregister("auth");
}
$server = &$this->_importGlobalVariable("server");
$server['PHP_AUTH_USER'] = "";
$server['PHP_AUTH_PW'] = "";
$GLOBALS['HTTP_SERVER_VARS']['PHP_AUTH_USER'] = "";
$GLOBALS['HTTP_SERVER_VARS']['PHP_AUTH_PW'] = "";
}
I tried to blank all occurrences of the PHP_AUTH_* variables... no success.
Where are these values coming from ??
I'll be glad to hear any successful approach !
-- Daniel