$_ENV["REMOTE_USER"] lost

Need help installing PHP, configuring a script, or configuring a server? Then come on in and post your questions! We'll try to help the best we can!

Moderator: General Moderators

Post Reply
jgt
Forum Newbie
Posts: 12
Joined: Thu Nov 02, 2006 6:07 am

$_ENV["REMOTE_USER"] lost

Post by jgt »

Hi all,
I'm migrating an old server that is running Apache/1.3.27 and PHP/4.3.1 on Windows NT to another HW running Apache/2.2.8 and PHP/5.2.6 on Windows XP.

On old server I have lot of scripts that are using $_ENV["REMOTE_USER"] to know which has been the user authorized to get in by Apache auth module.

On new server, using phpinfo, it seems that this array index is still existing but when I try to read the value I get an error. The print_r for $_ENV shows me that there isn't defined. But the phpinfo shows me the correct value.

I've modified the variables_order from "GPCS" to "EGPCS" but no efect.

How can I configure PHP to read this value?

Thanks.
User avatar
ghurtado
Forum Contributor
Posts: 334
Joined: Wed Jul 23, 2008 12:19 pm

Re: $_ENV["REMOTE_USER"] lost

Post by ghurtado »

Is the new server running PHP as a CGI?
jgt
Forum Newbie
Posts: 12
Joined: Thu Nov 02, 2006 6:07 am

Re: $_ENV["REMOTE_USER"] lost

Post by jgt »

Yes it is.
User avatar
ghurtado
Forum Contributor
Posts: 334
Joined: Wed Jul 23, 2008 12:19 pm

Re: $_ENV["REMOTE_USER"] lost

Post by ghurtado »

That could be your problem. Certain environment variables related to apache are only available when you run PHP as a Module, since the information that Apache shares with PHP is more complete that way.
jgt
Forum Newbie
Posts: 12
Joined: Thu Nov 02, 2006 6:07 am

Re: $_ENV["REMOTE_USER"] lost

Post by jgt »

Is this a change on new versions? My old server is running fine with same scripts and variable usage.

Thanks.
User avatar
ghurtado
Forum Contributor
Posts: 334
Joined: Wed Jul 23, 2008 12:19 pm

Re: $_ENV["REMOTE_USER"] lost

Post by ghurtado »

Was the old server running as an Apache module?
jgt
Forum Newbie
Posts: 12
Joined: Thu Nov 02, 2006 6:07 am

Re: $_ENV["REMOTE_USER"] lost

Post by jgt »

No, the old server is running as a CGI too.
User avatar
ghurtado
Forum Contributor
Posts: 334
Joined: Wed Jul 23, 2008 12:19 pm

Re: $_ENV["REMOTE_USER"] lost

Post by ghurtado »

In that case I am at a loss. I assume you already know that $_ENV["REMOTE_USER"] is only available when a user has authenticated via basic browser auth popup (not "in page" authentication), but other than that I do not know what else could be the problem.
jgt
Forum Newbie
Posts: 12
Joined: Thu Nov 02, 2006 6:07 am

Re: $_ENV["REMOTE_USER"] lost

Post by jgt »

Thanks for your effort. I'm still investigating how can I solve this issue. At least I can write a global funcion that uses getenv instead to query the $_ENV array itself. Not polite but I hope useful.
User avatar
ghurtado
Forum Contributor
Posts: 334
Joined: Wed Jul 23, 2008 12:19 pm

Re: $_ENV["REMOTE_USER"] lost

Post by ghurtado »

If you can get it via getenv then it is really strange. Is the value present in $_SERVER ?
jgt
Forum Newbie
Posts: 12
Joined: Thu Nov 02, 2006 6:07 am

Re: $_ENV["REMOTE_USER"] lost

Post by jgt »

Hello ghurtado.
sorry for the delay. I've been "disconnected" for some time.

Yes, the value is present in $_SERVER, as REMOTE_USER and also as PHP_AUTH_USER.
The result for getenv("REMOTE_USER") returns the correct value. But The array $_ENV doesn't contains the array member for this value.
jgt
Forum Newbie
Posts: 12
Joined: Thu Nov 02, 2006 6:07 am

Re: $_ENV["REMOTE_USER"] lost

Post by jgt »

I have now PHP running as Module and the same behavior.

Confused.
User avatar
ghurtado
Forum Contributor
Posts: 334
Joined: Wed Jul 23, 2008 12:19 pm

Re: $_ENV["REMOTE_USER"] lost

Post by ghurtado »

I think the value for remote_user may have been moved from the $_ENV array to the $_SERVER array in some version of PHP. I would go with $_SERVER, which is more recent and less likely to change in the future.
jgt
Forum Newbie
Posts: 12
Joined: Thu Nov 02, 2006 6:07 am

Re: $_ENV["REMOTE_USER"] lost

Post by jgt »

Ok.
I suposed something similar.

Thanks for your effort.

Hope this thread could be useful for others that have the same question (I'm not the first).
Post Reply