4

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?

Sebastian G. Marinescu
  • 2,374
  • 1
  • 22
  • 33
Badal
  • 3,738
  • 4
  • 33
  • 60

1 Answers1

8

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'];
?>
Community
  • 1
  • 1
user2959229
  • 1,360
  • 2
  • 11
  • 21