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

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
petersterling
Forum Newbie
Posts: 1
Joined: Thu Jan 14, 2010 7:34 am

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

Post 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
User avatar
requinix
Spammer :|
Posts: 6617
Joined: Wed Oct 15, 2008 2:35 am
Location: WA, USA

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

Post 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"].
Post Reply