PDA

View Full Version : Question on Session Authentication



dophinsluv
06-17-2007, 02:45 PM
I want to do the following:
1. Determine if a username has been entered.
1a. If yes determine if user is authorized. (go to 2 below)
1b. If no, send login header
2. Determine if user is authorized
2a. If yes display password protected data
2b. If no, send login header

When I run this:



if(!isset($_SERVER['PHP_AUTH_USER'],$_SESSION['auth']))
{
try
{
$prompter = new PasswordPrompter("secret section");
// gets here
$prompter->displayPrompt();
// never gets here

}
catch(Exception $e)
{
echo $e->getMessage();
exit();
}
}


It won't authorize with the correct username!

Any ideas why not?

Thanks

Pethens
06-17-2007, 03:26 PM
When PHP is running in CGI mode (as it does here at Bluehost), you can't use HTTP authorization from PHP:
http://www.php.net/features.http-auth

Either write your own login page in PHP or just use cPanel password protect for the directory, would be my advice.