xxxxxxxxxx
if (isset($_SERVER["HTTP_AUTHORIZATION"]) && 0 === stripos($_SERVER["HTTP_AUTHORIZATION"], 'basic ')) {
$exploded = explode(':', base64_decode(substr($_SERVER["HTTP_AUTHORIZATION"], 6)), 2);
if (2 == count($exploded)) {
list($username, $password) = $exploded;
}
}
Some web servers will parse the basic auth header name differently depending on your web server server you'll find it with different names, a print_r($_SERVER) should help you find it but generally:
xxxxxxxxxx
$_SERVER["HTTP_AUTHORIZATION"] - NGINX
$_SERVER["REMOTE_USER"] - CGI standard
$_SERVER["PHP_AUTH_USER"] - APACHE
$_SERVER["AUTH_USER"] - IIS