MacBook avec code sur un bureau

PHP – NGINX: How to pass the PHP_AUTH_USER and PHP_AUTH_PW variables

In the Nginx configuration, just add the configuration

fastcgi_param $http-authorization if_not_empty HTTP_AUTHORIZATION;

so that the authentication variables are filled in.

On the PHP side, to retrieve them

$username - $_SERVER['PHP_AUTH_USER'];
$password - $_SERVER['PHP_AUTH_PW'];

Leave a comment