Mailinglisten-Archive |
Tach Leute,
mir brennt ein Problem! Ich nutze die Variablen $PHP_AUTH_USER und
$PHP_AUTH_PW zur Autorisierung. Funktioniert mit beiliegenden Code
wunderbar.
Nun möchte ich mich aber wieder ausloggen und habe bemerkt, dass es mit
unset($PHP_AUTH_USER) nicht klappt. Denn nach dem Refresh steht der
Benutzername wieder innerhalb der Variable.
<?php
$auth = false; // Assume user is not authenticated
if (isset($PHP_AUTH_USER) && isset($PHP_AUTH_PW))
{
// Formulate the query
$sql = "SELECT * FROM memaccount WHERE
benutzer = '$PHP_AUTH_USER' AND
passwort = password('$PHP_AUTH_PW')";
// Execute the query and put results in $result
$result = mysql_query($sql) or die (mysql_errno().":
".mysql_error()."<br>".
'Unable to execute query [1 in authentication].');
// Get number of rows in $result.
$num = mysql_numrows($result);
if ($num != 0)
{
// A matching row was found - the user is authenticated.
$auth = true;
}
mysql_free_result($result);
}
if (!$auth)
{
header('WWW-Authenticate: Basic realm="[Out of Sync Net e.V.] intern"');
header('HTTP/1.0 401 Unauthorized');
# header ("Location: $PHP_SELF?searchlinkname=BADLOGIN"); /* Umleitung
des Browsers
# zur PHP-Web-Seite. */
print_javascript("location.href =
\"$PHP_SELF?searchlinkname=BADLOGIN\"");
# echo 'Authorization Required.';
exit;
}
else
{
# => You are authorized!
}
?>
Wie kann ich mich ausloggen???
Vielen Dank.
Ciao
Alexander Manhart
php::bar PHP Wiki - Listenarchive