PHP and .htaccess ???

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
Neil Hillman
Forum Newbie
Posts: 1
Joined: Mon May 17, 2004 4:20 am
Location: Geneva, Switz.

PHP and .htaccess ???

Post 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
dave420
Forum Contributor
Posts: 106
Joined: Tue Feb 17, 2004 8:03 am

Post 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.
User avatar
delorian
Forum Contributor
Posts: 223
Joined: Sun May 04, 2003 5:20 pm
Location: Olsztyn, Poland

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