Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Obtain username after logon to .htaccess protected folder

Status
Not open for further replies.

dkdude

Programmer
Jun 16, 2003
849
DK
Hi,

How is it possible with PHP (is it possible?) to obtain the username of someone after he/she has logged into a folder protected by .htaccess?

Thanks


Jakob
 
You should be able to access the username entered via the HTTP authentication prompt using:
Code:
$_SERVER['PHP_AUTH_USER'];

See for more info.

Clive
Runner_1Revised.gif

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
"To err is human, but to really foul things up you need a computer." (Paul Ehrlich)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
To get the best answers from this forum see: faq102-5096
 
if you are using php as a SAPI, ISAPI, of course. There is also a php version dependency on IIS.
 
Thanks

Nope -don't work. I'm runnig on a linux system with PHP5. Tried turning register globals both on and off. Even tried $HTTP_SERVER_VARS... still no result.

Any suggestions as to why? Please advice.

Thanks again
 
are using php as a SAPI or a CGI? it does not work with a CGI.
 
To be honest, I'm not quite sure, jpadie... how can I tell? phpinfo()?

Thanks
 
have a look in your httpd.conf.

but yes, phpinfo should give you a hint. it will have a field for server api if you are running a SAPI (server api ...) and a field for CGI version if [wait for it...] you are running CGI!
 
Thanks!

phpinfo() says ...

Server API : CGI/FastCGI

... so it can't be done, right?

Would I be able to fetch something from the server log to help me get the user name? Too unsafe, perhaps :)

Looks like I'm stuck with sessions - sessions requires that the client accepts cookies, right?

Regards
 
Hey -got it working with $_SERVER["REMOTE_USER"] ... thanks for your hints!

Regards
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top