logout with apache authentication
| From: | Chris Lee | Date: | Tue, 21 Nov 2000 08:40:04 +0000 |
| Subject: | logout with apache authentication | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-26545@lists.php.net to get a copy of this message | ||
Im playing with authentication here's what I have.
<?
include_once("cookie.egn");
include_once("database.egn");
if ( isset($PHP_AUTH_USER) AND isset($PHP_AUTH_PW)
AND $peop_r = fetch_db_value("people", "WHERE username = '$PHP_AUTH_USER'
AND passwd = '$PHP_AUTH_PW' ") )
$SessionID = $peop_r["peopleID"];
else
{
Header("WWW-Authenticate: Basic realm='$SERVER_NAME' ");
Header("HTTP/1.0 401 Unauthorized");
echo "Bad Passwd<br>\n";
exit();
}
echo "<a href='$PHP_SELF?logout=1'>Logout</a>\n";
?>
fetch_db_value is just a simple function I have for accessing MySQL
$SessionID is a session variable.
What you can see is that I want a logout button, I cant get it to work
like I want it to.
if I change the if () statment to
...
if ( !isset($logout) AND isset($PHP_AUTH_USER) AND isset($PHP_AUTH_PW)
AND $peop_r = fetch_db_value("people", "WHERE username = '$PHP_AUTH_USER'
AND passwd = '$PHP_AUTH_PW' ") )
...
I get a recursive loop, I enter a valid username / password and I have to
login again. because the $logout variable is still set.
Chris Lee
Mediawaveonline.com