Page 1 of 1

PHP and .htaccess ???

Posted: Mon May 17, 2004 4:20 am
by Neil Hillman
Can anyone please tell me:

If you set up an .htaccess user:password on a directory, so that the user must login to access scripts within that directory, is it possible to tell from within the PHP script they are accessing, which user is logged in?
(ie. which username they used to login via .htaccess?)

Thank you! :wink:

Neil

Posted: Mon May 17, 2004 4:25 am
by dave420
Look in the manual under "HTTP authentication with PHP", and you'll see you can do authentication in PHP, without using .htaccess files. Through this method, you will have no problems telling which user is logged on.

Posted: Mon May 17, 2004 11:23 am
by delorian
Read also about predefined variables in $_SERVER array. Especialy look for PHP_AUTH_USER and PHP_AUTH_PW. That is all what you need.