Page 1 of 1

Can PHP tell if the dir a script is running in is secured?

Posted: Thu Jan 14, 2010 7:39 am
by petersterling
How can a PHP script determine if it is running in a directory secured by Apache? That is, has the user been challenged to enter a username and password to enable Apache to serve pages from a directory secured by it's .htaccess file with "AuthType Basic" etc. directives.

Thanks in advance.
Pete

Re: Can PHP tell if the dir a script is running in is secured?

Posted: Thu Jan 14, 2010 8:00 am
by requinix
For Basic authentication you'll have $_SERVER["PHP_AUTH_USER"] and $_SERVER["PHP_AUTH_PW"].
For Digest you get $_SERVER["PHP_AUTH_DIGEST"].