Forum Moderators: coopster

Message Too Old, No Replies

User Authentication Using .htaccess/httpd.conf

Is there a PHP variable that can tell what user logged in?

         

wfernley

3:00 pm on Feb 23, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Hello,

I currently have a password protected page that users have to login to view. The authentication method is done in Apache with a password file. So this means the server asked for a username and password and not an actual webpage.

I was curious if there is a way in PHP that I can find out what the username was that the user logged in with.

Does anyone know how to do this?

Thanks!

Wes

coopster

5:45 pm on Feb 23, 2006 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



They are likely in your $_SERVER superglobal as indexes:
$_SERVER['PHP_AUTH_USER'] 
$_SERVER['PHP_AUTH_PW']

There is a handy utility program in our PHP Forum Library [webmasterworld.com] that will help you view all kinds of variables during development. It's in message # 2 of Good PHP solutions to small problems [webmasterworld.com].

wfernley

7:13 pm on Feb 23, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Thanks coopster!

Thats what I was looking for.

Cheers!