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 Wanet Telecoms Ltd on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Accessing username typed to the .htaccess authorization dialog 1

Status
Not open for further replies.

gizmicek

Programmer
Jun 25, 2003
107
CZ
Hallo all,
recently I came across password protecting web pages using .htaccess feature of Apache. I'd like to ask those of you who have some experience with this feature if there is some way to obtain the username typed by user and use it in PHP script (eg. index.php which is automatically displayed after succesfull login through the .htaccess Apache feature). I need this to be able to find out the username of the user who logged to the pages. I know there are other ways to password protect web pages, but I'd like to use this one.

So in general I'd like to know, if the username typed into the authorization dialog of .htaccess is somehow accessible in PHP script (eg. through some variable).

Thanx for all replies, Peter
 
If you are just using Basic authentication, it is possible. Use the [tt]$_SERVER['PHP_AUTH_USER'][/tt] and [tt]$_SERVER['PHP_AUTH_PW'][/tt] to access the credentials.

//Daniel
 
It seems that the webhosting service where my pages are located don't have php as an Apache module, cause $_SERVER['PHP_AUTH_USER'] is not available. I will probably have to do the authentification using php headers. Thanx for your replies anyway!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top