How can I use Basic HTTP Authentication in PHP?

前端 未结 5 2035
心在旅途
心在旅途 2020-12-09 17:16

I\'m trying to use Basic HTTP Authentication and followed the example on the PHP manual page. But it doesn\'t work for me. The variable $_SERVER[\'PHP_AUTH_USER\']

5条回答
  •  情歌与酒
    2020-12-09 17:55

    Check if you have overrided your variable $_SERVER[‘PHP_AUTH_USER’] and$_SERVER[‘PHP_AUTH_PW’] before the place where you are trying to access the both variables.

    If above is not the case then chek if you are using php as cgi mod or not. IF you are using php as cgi mod then in the most of case you will not get $_SERVER[‘PHP_AUTH_USER’] and$_SERVER[‘PHP_AUTH_PW’] because generraly we do not compile the apache with option SECURITY_HOLE_PASS_AUTHORIZATION So if you want to get both variable then re-compile apache with option SECURITY_HOLE_PASS_AUTHORIZATION or you can use .htaccess approach.

提交回复
热议问题