Normally when a publicly-accessible directory requires basic HTTP authentication, the value of $_SERVER['HTTP_AUTHORIZATION']
and/or $_SERVER['REMOTE_USER']
(or $_SERVER['PHP_AUTH_USER']
, etc) will be set and accessible to PHP once a valid username/password combination have been provided to the server.
For example, if http://www.example.com/members
requires basic authentication, and a user successfully authenticates using the credentials myusername
and mypassword
by manually typing http://myusername:mypassword@www.example.com/members
into their browser, the value of $_SERVER['HTTP_AUTHORIZATION']
would be something like:
Basic bXl1c2VybmFtZTpteXBhc3N3b3Jk
... and the value of $_SERVER['REMOTE_USER']
would simply be:
myusername
However if authentication is not required in the same directory, but the URL is still visited with the username/password inside of it, the values of the username/password don't seem to be set anywhere (running PHP 5.3.10 as CGI/FastCGI on Apache/2.2.22).
From within PHP (and/or .htaccess
if necessary), when no authentication is required, is there a way to retrieve the values of the username (and/or password) that have been provided by a visitor who manually added them to the URL?