简体   繁体   中英

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?

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'];
?>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM