faqts : Computers : Programming : Languages : PHP : Common Problems : Tips and Tricks

+ Search
Add Entry AlertManage Folder Edit Entry Add page to http://del.icio.us/
Did You Find This Entry Useful?

72 of 107 people (67%) answered Yes
Recently 8 of 10 people (80%) answered Yes

Entry

How can I get the name of the user logged in using HTTP authentication?
What is the REMOTE_USER apache variable for?

Jul 6th, 2004 10:35
Philip Olson, matt wilkie, Jason Granum, Nathan Wallace, Brent Bearden, Richard Lynch


REMOTE_USER is the name of the user currently logged in using HTTP
authentication.
It is available in PHP as the variable:
    $_SERVER['REMOTE_USER']
It it also available in PERL as the variable:
    $ENV{REMOTE_USER}
REMOTE_USER is set by Apache, or not, depending on the whim of the
configuration in httpd.conf  More information on setting up HTTP 
Authentication can be seen in this article:
  Using User Authentication:
  -----------------------------------------------------------------
  http://www.apacheweek.com/features/userauth
See also this faq:
  Why is the environment variable REMOTE_USER not set? 
  -----------------------------------------------------------------
  http://httpd.apache.org/docs/misc/FAQ-F.html#remote-user-var
In regards to PHP specific information, read the PHP manual here:
  HTTP authentication with PHP:
  -----------------------------------------------------------------
  http://us2.php.net/manual/en/features.http-auth.php