Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Finding current user from htaccess

Status
Not open for further replies.
Dec 16, 2002
101
GB
Hi
Is there anyway of determining the name of the current user when htaccess authentication is used. For example a site with 20 users, if a user 'john' authenticates where can I find this and use these values for the session.
Also, how would I get this value from php or perl.
Thanks
Chris
 
If you are working with Apache, it sets the REMOTE_USER environment variable to the name of the authenticated user. You can retrieve it with PHP as simply as:

$remote_user = getenv("REMOTE_USER");

HOWEVER, be careful, you're counting on Apache and the end-user to be truthful, honest, unhacked, etc... You should consider using a security solution that is consistent with your risks.

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top