Before starting, I would like to indicate that I looked at Qaru and found other similar questions - PHP_AUTH_USER not installed? and HTTP Auth via PHP - PHP_AUTH_USER not installed? - and they indicated that the authentication variables $ _SERVER will not be set if the "Server API" is set to "CGI / FCGI", but I checked my output "phpinfo ()" and my "Server API" is set to "Apache 2.0 Handler."
So, I have a simple script as follows:
<?php echo "Username: " . $_SERVER["PHP_AUTH_USER"] . ", Password: " . $_SERVER["PHP_AUTH_PW"]; ?>
... which I call remotely through the following:
wget -v --http-user=johnsmith --http-password=mypassword http:
... but which only outputs:
Username: , Password:
I also tried calling the script using PHP cURL and setting the authentication parameters correctly as follows:
curl_setopt($ch, CURLOPT_USERPWD, "johnsmith:mypassword");
... but I get the same result as above.
Any idea what I'm doing wrong? Perhaps there is something else that I need to enable / configure?
source share