Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I get the authenticated user name under Apache using plain HTTP authentication and PHP?

First, let's get the security considerations out of the way. I'm using simple authentication under Apache for a one-off, internal use only, non-internet connected LAN, PHP web app.

How can get I the HTTP authenticated user name in PHP?

like image 386
basszero Avatar asked Aug 04 '08 17:08

basszero


People also ask

How do I authenticate a user in PHP?

Once the user has filled in a username and a password, the URL containing the PHP script will be called again with the predefined variables PHP_AUTH_USER , PHP_AUTH_PW , and AUTH_TYPE set to the user name, password and authentication type respectively. These predefined variables are found in the $_SERVER array.

Where are the username and password stored in a PHP program when using HTTP authentication?

PHP provides superglobal variables for HTTP authentication, the $_SERVER['PHP_AUTH_USER'] and $_SERVER['PHP_AUTH_PW'] contain the username and password provide by the user for authentication.


1 Answers

I think that you are after this

$username = $_SERVER['PHP_AUTH_USER']; $password = $_SERVER['PHP_AUTH_PW']; 
like image 100
Teifion Avatar answered Sep 18 '22 21:09

Teifion