Page 1 of 1
$_ENV["REMOTE_USER"] lost
Posted: Fri Aug 08, 2008 6:47 am
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.
Re: $_ENV["REMOTE_USER"] lost
Posted: Fri Aug 08, 2008 7:37 am
by ghurtado
Is the new server running PHP as a CGI?
Re: $_ENV["REMOTE_USER"] lost
Posted: Fri Aug 08, 2008 10:21 am
by jgt
Yes it is.
Re: $_ENV["REMOTE_USER"] lost
Posted: Fri Aug 08, 2008 11:06 am
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.
Re: $_ENV["REMOTE_USER"] lost
Posted: Sat Aug 09, 2008 2:39 am
by jgt
Is this a change on new versions? My old server is running fine with same scripts and variable usage.
Thanks.
Re: $_ENV["REMOTE_USER"] lost
Posted: Mon Aug 11, 2008 8:32 am
by ghurtado
Was the old server running as an Apache module?
Re: $_ENV["REMOTE_USER"] lost
Posted: Tue Aug 12, 2008 3:08 am
by jgt
No, the old server is running as a CGI too.
Re: $_ENV["REMOTE_USER"] lost
Posted: Tue Aug 12, 2008 8:26 am
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.
Re: $_ENV["REMOTE_USER"] lost
Posted: Tue Aug 12, 2008 9:50 am
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.
Re: $_ENV["REMOTE_USER"] lost
Posted: Tue Aug 12, 2008 9:59 am
by ghurtado
If you can get it via getenv then it is really strange. Is the value present in $_SERVER ?
Re: $_ENV["REMOTE_USER"] lost
Posted: Tue Aug 19, 2008 2:09 am
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.
Re: $_ENV["REMOTE_USER"] lost
Posted: Thu Aug 21, 2008 4:29 am
by jgt
I have now PHP running as Module and the same behavior.
Confused.
Re: $_ENV["REMOTE_USER"] lost
Posted: Thu Aug 21, 2008 7:38 am
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.
Re: $_ENV["REMOTE_USER"] lost
Posted: Thu Aug 21, 2008 8:13 am
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).