HTTP AUTH with php5
| From: | Dynamix | Date: | Wed, 28 Apr 2004 15:45:52 +0000 |
| Subject: | HTTP AUTH with php5 | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-184895@lists.php.net to get a copy of this message | ||
Greetings,
I'm running php5 under windows and apache 1.x , the HTTP authentification
isn't working, i checked globals and the variable $_SERVER['PHP_AUTH_USER']
wasn't defined at all, any help how to fix this ?
Thanks,
Hatem
function authenticate()
{
header('WWW-Authenticate: Basic realm="Test Authentication System"');
header('HTTP/1.0 401 Unauthorized');
echo "Vous devez entrer un identifiant et un mot de passe valide pour
accéder
à cette ressource.\n";
exit;
}
if ( !isset($_SERVER['PHP_AUTH_USER']) ||
($_POST['SeenBefore'] == 1 && $_POST['OldAuth'] ==
$_SERVER['PHP_AUTH_USER'])) {
authenticate();
} else {
echo "<p>Welcome: {$_SERVER['PHP_AUTH_USER']}<br>";
echo "Old: {$_REQUEST['OldAuth']}";
echo "<form action='{$_SERVER['PHP_SELF']}'
method='POST'>\n";
echo "<input type='hidden' name='SeenBefore'
value='1'>\n";
echo "<input type='hidden' name='OldAuth'
value='{$_SERVER['PHP_AUTH_USER']}'>\n";
echo "<input type='submit' value='Re Authenticate'>\n";
echo "</form></p>\n";
}