Basic PHP authentication
posted in /home/PHP on 2011-10-17 |
The .htaccess file is actually a possible solution for this purpose. The problem with this approach is that the value of AuthUserFile should contain an absolute path. It also works with relative paths, but it is relative based on ServerRoot, which in most of the cases is different from DocumentRoot. I also didn't want to deal with sessions or cookies and after a short research I found the answer.
And the usage:
The result is similar to the one provided by .htaccess solution. Have in mind that it is possible to have $_SERVER['PHP_AUTH_USER'] and $_SERVER['PHP_AUTH_PW'] set already.
And the usage:
The result is similar to the one provided by .htaccess solution. Have in mind that it is possible to have $_SERVER['PHP_AUTH_USER'] and $_SERVER['PHP_AUTH_PW'] set already.
Delicious