Forum Moderators: coopster

Message Too Old, No Replies

user authentication

         

welldressedmatt

9:01 pm on Aug 22, 2007 (gmt 0)

10+ Year Member



I am using my webhost's username and password system, which generates .htaccess and .htpasswd user verification (Bluehost).

I want users to login to the password protected subdirectory (let's say www.example.com/clients/) with the browser's default login dialog box, which is all automated by Apache and the web browser...

But once they are logged in, I want the target page (www.example.com/clients/index.php) to read the username that they logged in with and redirect them to a subdirectory with that name (www.example.com/clients/username/). Is there a way for PHP to read the username that they logged in with through Apache? Perhaps some kind of HTTP request that will return the username as a variable?

Thanks!

[edited by: eelixduppy at 9:11 pm (utc) on Aug. 22, 2007]
[edit reason] switched to example.com [/edit]

Little_G

9:06 pm on Aug 22, 2007 (gmt 0)

10+ Year Member



Hi,

That information can be accessed via the $_SERVER [php.net] array with PHP_AUTH_USER and PHP_AUTH_PW.

Andrew

welldressedmatt

10:29 pm on Aug 22, 2007 (gmt 0)

10+ Year Member



Doesn't the PHP_AUTH_USER element only work if PHP is running as an Apache module? If I'm not mistaken, Bluehost (our webhost) runs PHP in CGI mode.

Little_G

12:01 am on Aug 23, 2007 (gmt 0)

10+ Year Member



Hi,

Yes PHP_AUTH_USER does only work with PHP as an Apache module, I have no idea what Bluehost use.
If you dump the $_SERVER and $_ENV arrays:

var_dump($_SERVER,$_ENV);
Bluehost's config may be forwarding you the information via another variable, if your lucky! If not then I don't know I there's any other way of getting it.

Andrew