cancel
Showing results for 
Search instead for 
Did you mean: 

$_SERVER['PHP_AUTH_USER'] command problem

N/A

$_SERVER['PHP_AUTH_USER'] command problem

On the old CGI this worked fine and returned values:

if (!isset($_SERVER['PHP_AUTH_USER']))
{ header('WWW-Authenticate: Basic realm="LMW Product Manuals"');header('HTTP/1.0 401 Unauthorized'); }
else
{ $username=$_SERVER['PHP_AUTH_USER']; $password=$_SERVER['PHP_AUTH_PW'];
}

On the new one I cannot find any values from the dialogue to login being returned.

I think it may be to do with being in safe mode but a call to get what state the safe mode commend is in returns no value either.

Anyone any ideas, or work arounds, other than moving my website??


Peter
4 REPLIES
Ben_Brown
Grafter
Posts: 2,839
Registered: 13-06-2007

$_SERVER['PHP_AUTH_USER'] command problem

I've tried this on both old and new servers with similar results.

<?php

if (!isset($_SERVER['PHP_AUTH_USER']))
{ header('WWW-Authenticate: Basic realm="LMW Product Manuals"');header('HTTP/1.0 401 Unauthorized'); }
else
{ $username=$_SERVER['PHP_AUTH_USER']; $password=$_SERVER['PHP_AUTH_PW'];
}
echo "$username<br>$password<br>"
?>


On the old server it works as expected, however on the new one it gives me a login prompt, but I can't get any further. Unfortunately I can't get any more info at the moment, I'll try and get more on this as soon as I can.
N/A

$_SERVER['PHP_AUTH_USER'] command problem

This page (http://www.zend.com/manual/features.http-auth.php) seems to suggest it only works when PHP is running as an apache module, not as CGI.

Quote
"The HTTP Authentication hooks in PHP are only available when it is running as an Apache module and is hence not available in the CGI version."


Could it be the new server is running PHP as a cgi exe?
N/A

$_SERVER['PHP_AUTH_USER'] command problem

Thanks,

I await to see what F9 have worked out. I doubt I'm the only one doing this. I think they must be scatching their heads quite a lot.

I guess I must be about to go off the air......
Ben_Brown
Grafter
Posts: 2,839
Registered: 13-06-2007

$_SERVER['PHP_AUTH_USER'] command problem

Hi there,

I've now discovered that we are running PHP as CGI rather than an apache module, so we can get the scripts to run as their owner rather than a generic wwwuser account.

Unfortunately this means that this authentication method will not work on the new CGI platform.