Is it possible to allow different logins for the same program using .htaccess and then query in PHP who has logged in?

It is possible to allow different logins for the same program using .htaccess by setting up multiple authentication realms. In PHP, you can retrieve the username of the logged-in user using the $_SERVER['PHP_AUTH_USER'] variable. By checking this variable, you can determine who has logged in.

<?php
$loggedInUser = $_SERVER['PHP_AUTH_USER'];

if ($loggedInUser) {
    echo "Logged in as: $loggedInUser";
} else {
    header('WWW-Authenticate: Basic realm="Restricted Area"');
    header('HTTP/1.0 401 Unauthorized');
    echo 'Access denied.';
    exit;
}
?>