Question

ı updated and modified some app and i needed to add http basic auth for some reason. It runs on locol machine perfectly but not on production server. It keeps asking username and password repeadetly. Here is code waiting for your help.

<?php
if (!isset($_SERVER['PHP_AUTH_USER'])) {
    header('WWW-Authenticate: Basic realm="Some Tex"');
    header('HTTP/1.0 401 Unauthorized');
    echo 'Some warning.';
    exit;
} else {t

}
$apikey = "http://{$_SERVER['PHP_AUTH_USER']}:{$_SERVER['PHP_AUTH_PW']}@someaddress.net/somefolder/some.xml";
$xml=simplexml_load_file($apikey);

Waiting for your precious answers.

Was it helpful?

Solution

So for those who have a problem with $_SERVER['PHP_AUTH_USER'] They first need to check their ServerAPI from phpinfo();if it is CGI there is no way to use $_SERVER['PHP_AUTH_USER']
You need to recompile PHP.

It turns out that my SERVER API for php is FastCGI.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top