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 Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Authenticated username 1

Status
Not open for further replies.

RobBroekhuis

Technical User
Oct 15, 2001
1,971
US
I have directory-level authentication set up for some parts of my website. Accessing pages within these directories requires me to log in (or face a 403), and my being logged in is reflected in the server logs, e.g.
Code:
##.27.156.146 - MyUserName [05/Nov/2004:10:12:02 -0500] "GET /play/auth.php HTTP/1.1" 200 21 admin.mydomain.com "-" "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.0; .NET CLR 1.0.3705; .NET CLR 1.1.4322)" "-"

where MyUserName is the user name entered into the HTTP authentication window. Apache clearly knows about the username - is there any way for me to get that information from my PHP scripts? I tried using the $_SERVER['PHP_AUTH_USER'] global, but it only applies to PHP page-level authorization.


Rob
[flowerface]
 
Are you running PHP as an Apache module or as a CGI?

To the best of my knowledge, $_SERVER['PHP_AUTH_USER'] and $_SERVER['PHP_AUTH_PW'] are only available when running PHP as an Apache module.


Want the best answers? Ask the best questions!

TANSTAAFL!!
 
I don't actually know. My site is hosted on an Apache-driven server, I use SSH to access a Unix-type commandline environment. PHP is installed as an executable somewhere in the usr/local/bin structure. Does that make it an Apache module?

Rob
[flowerface]
 
Insufficient data for a meaningful answer.

On most Unix-like OSes, even when you install PHP as an Apache module, a stand-alone interpreter is also installed. So knowing that the standalone PHP interpreter is at /usr/local/bin/php doesn't tell us much.


Do you have to prepend the line:

#! /usr/local/bin/php

to the beginnings of your scripts?


If you run a script which consists of:

<?phpinfo();?>

What does the "Server API" entry say?


Want the best answers? Ask the best questions!

TANSTAAFL!!
 
Okay - I certainly do not prepend anything to the beginnings of my scripts. But the Server API says CGI. Is that contradictory?

Rob
[flowerface]
 
OK. I'll have to program around it with cookies, then.
Thanks for your help.


Rob
[flowerface]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top