Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to get logged in user's name from .htpasswd?

I have a password protected directory with htaccess and htpasswd.

My .htpasswd file looks like this:

user1:passwordstring
user2:passwordstring
user3:passwordstring

When any of the user login successfully into the directory is there anyway I can get that user's name using php?

like image 350
Badal Avatar asked Oct 27 '25 09:10

Badal


1 Answers

Assuming that I've understood the question correctly, your answer is here. More reference.

<?php
$username = $_SERVER['PHP_AUTH_USER'];
$password = $_SERVER['PHP_AUTH_PW'];
?>
like image 142
user2959229 Avatar answered Oct 28 '25 23:10

user2959229