8

I tried to update the php version of my VPS but it didn't work and my provider didn't help me well, so i downgrade it to the previous version.

I am now working with PHP 5.2.17 (cli). Everything was working properly in this version.

Since this upgrade and downgrade, the variable $_SERVER['PHP_AUTH_USER'] is empty. (In the php.ini, register_globals is 'on' and $_SERVER['PHP_SELF'] is properly working).

It ask me properly my username and password and i success to connect but i need to use $_SERVER['PHP_AUTH_USER'].

I tried $_SERVER['PHP_AUTH_USER'], $_SERVER['AUTH_USER'], $_SERVER['REMOTE_USER'] nut none is working. (but im never getting any error, just a blank value...)

4

2 回答 2

13

感谢'mbinette',我终于找到了答案。

在我的 PHP 配置中,PHP 5 的处理程序是 CGI,这种类型的身份验证不适用于 PHP CGI。所以我把它改成了 suPHP(这应该是 APACHE 上的默认值)。

在这里找到一篇解释使用 CGI 和 PHP_AUTH 的方法的帖子,但我试过了,但它不起作用。

在这里找到一些关于 php 处理程序的解释

于 2012-09-24T03:08:51.703 回答
3

Is safe mode activated? That might be your problem...

As of PHP 4.3.0, in order to prevent someone from writing a script which reveals the password for a page that was authenticated through a traditional external mechanism, the PHP_AUTH variables will not be set if external authentication is enabled for that particular page and safe mode is enabled. Regardless, REMOTE_USER can be used to identify the externally-authenticated user. So, you can use $_SERVER['REMOTE_USER'].

Source: http://php.net/manual/en/features.http-auth.php

于 2012-09-24T02:10:22.353 回答