Retrieve active user from .htpasswd

Hi all,

Currently to secure the access of a website, I use the combination of .htaccess and .htpasswd.
It's very powerful.

Now I want to go further and I need to retrieve the ID, defined in the .htpasswd, the user uses to be authentified.

Is it possible using PHP to get the value of the identifier ?

Thanks in advance.
Richard
LVL 1
Richard Coffree-commerce Product ManagerAsked:
Who is Participating?
 
Chris StanyonConnect With a Mentor Commented:
You should be able to access the info from the $_SERVER array:

<?php echo $_SERVER['REMOTE_USER']; ?>

Open in new window

0
 
Meir RivkinFull stack Software EngineerCommented:
try:
$_SERVER['PHP_AUTH_USER']

Open in new window

0
 
Ray PaseurCommented:
To see all the PHP variables and configuration values, run this script, shown here in its entirety.  The SERVER and ENV variables are near the bottom.  Some of this can be omitted by PHP and some of this is request data, and can therefore be an attack vector, but it's usually right most of the time when it is present.
<?php phpinfo();

Open in new window

0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.