note 21714 added to features.http-auth
| From: | louis dot carlier at ngroups dot com | Date: | Fri, 24 May 2002 00:22:06 +0000 |
| Subject: | note 21714 added to features.http-auth | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-30964@lists.php.net to get a copy of this message | ||
The definitive HTTP authorization code:
function login_error()
{
echo "error - login process failed."
}
if (!isset($PHP_AUTH_USER))
{
header("WWW-Authenticate: Basic realm=\"Mosaic Authorization process\"");
header("HTTP/1.0 401 Unauthorized");
//Result if user hits cancel button
login_error();
}
else
{
//check the login and password
if('=>test on login and password<=')
{
//User is logged
...
...
}
else
{
//This re-asks three times the login and password.
header( "WWW-Authenticate: Basic realm=\"Test Authentication System\"");
header("HTTP/1.0 401 Unauthorized");
//Result if user does not give good login and pass
login_error();
}
}
--
http://www.php.net/manual/en/features.http-auth.php
http://master.php.net/manage/user-notes.php?action=edit+21714
http://master.php.net/manage/user-notes.php?action=delete+21714
http://master.php.net/manage/user-notes.php?action=reject+21714