Forum Moderators: coopster
This is driving me nuts (actually, it's more of a short putt *<:o)
I have a feed that I really want to provide to the correct people.
Here's the teensy bit of code I use to extract the login and password:
header('WWW-Authenticate');
$login = $_SERVER['PHP_AUTH_USER'];
$password = $_SERVER['PHP_AUTH_PW'];
If this is passed, I use the login and password to log into the system, and open the gate to the feed.
I get an alert, asking for the password (GRR. It won't honor my RSS reader's embedded login and password).
I know that I'm doing SOMETHING wrong, because it isn't getting the right information and logging me in.
I can find almost zero information on the Web for the feed side. There's all kinds of stuff for the reader side, but that don't do me much good.
I'm sure the solution is absurdly simple. Any pointers to the correct M for me to RTFM would be appreciated.
HTTP authentication with PHP [php.net]
Try this out
if (!isset($_SERVER['PHP_AUTH_USER']))
{
header('WWW-Authenticate: Basic realm="My Realm"');
header('HTTP/1.0 401 Unauthorized');
echo 'You are not authorized to view this page.
exit;
}
$login = $_SERVER['PHP_AUTH_USER'];
$password = $_SERVER['PHP_AUTH_PW'];//validate user
if(!$valid)
{
header('WWW-Authenticate: Basic realm="My Realm"');
header('HTTP/1.0 401 Unauthorized');
echo 'Login or password incorrect. You are not authorized to view this page.
exit;
}
This should work for you.
Regards
Michal