...

View Full Version : SOLVED: using htaccess username in php script



SeeIT Solutions
11-13-2006, 04:34 AM
I want to use the browser login and use the login information.

http://seeitsolutions.com.au/layouts

For example, if you login with username and password, could php find who was logged in and use the username to determine what is displayed? If so, how do I get that info?

musher
11-13-2006, 05:02 AM
SeeIT,
Was that (the link) setup using directory protection? if it was I dont think php can pick up the user-id I cant think of any server variable that would have that info.
Why not just write a log-in page/script with MySQL in the back? if you need help with that let me know.

SeeIT Solutions
11-13-2006, 05:06 AM
Yes that was done by directory protection.

I didn't want to do that because I couldn't be bothered :) Also, the login determines what database it will access so the login would need to be hard coded.

SeeIT Solutions
11-13-2006, 06:33 AM
I use a webmail client that does this though. Horde webmail takes login from the browser and then uses that. So does cpanel.

musher
11-13-2006, 06:56 AM
I use a webmail client that does this though. Horde webmail takes login from the browser and then uses that. So does cpanel.


Yea SeeIt I use Horde to, but mine uses a login page/script. hmmm weird.

SeeIT Solutions
11-13-2006, 07:43 AM
After a lot of searching it is possible.

It is stored in the $_SERVER array under...


'PHP_AUTH_DIGEST'
When running under Apache as module doing Digest HTTP authentication this variable is set to the 'Authorization' header sent by the client (which you should then use to make the appropriate validation).


'PHP_AUTH_USER'
When running under Apache or IIS (ISAPI on PHP 5) as module doing HTTP authentication this variable is set to the username provided by the user.


'PHP_AUTH_PW'
When running under Apache or IIS (ISAPI on PHP 5) as module doing HTTP authentication this variable is set to the password provided by the user.


'AUTH_TYPE'
When running under Apache as module doing HTTP authenticated this variable is set to the authentication type.

That can be found at the php site here: http://php.net/manual/en/reserved.variables.php



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum