Before I begin, I'd like to point out that I've browsed Stack Overflow and found other similar questions - PHP_AUTH_USER not set? and HTTP Auth via PHP - PHP_AUTH_USER not set? - and these have pointed out that the authentication $_SERVER variables won't be set if ''Server API'' is set to ''CGI/FCGI'', but I checked my ''phpinfo()'' output and my ''Server API'' is set to ''Apache 2.0 Handler''.
Ok so I have a simple script as follows:
<?php echo "Username: " . $_SERVER["PHP_AUTH_USER"] . ", Password: " . $_SERVER["PHP_AUTH_PW"]; ?>
... which I am calling remotely via the following:
wget -v --http-user=johnsmith --http-password=mypassword http://www.example.com/myscript.php
... but which only outputs:
Username: , Password:
I have also tried calling the script using PHP cURL and setting the authentication parameters appropriately as follows:
curl_setopt($ch, CURLOPT_USERPWD, "johnsmith:mypassword");
... but I get the same output as above.
Any idea what I'm doing wrong? Perhaps there is something else I need to enable / configure?