Stut wrote:
On 18 Sep 2008, at 16:37, David Rocks wrote:
Stut wrote:
On 18 Sep 2008, at 05:57, David Rocks wrote:
I am running a test PHP web app on my local machine that uses
REMOTE_ADDR and most of the time ::1 is returned as the IP addr and
sometimes it is 127.0.0.1 . I am on OS X 10.5.5 and using APACHE 2.
PHPINFO always returns ::1 for REMOTE_ADDR. Is this a PHP or a
APACHE 2 thing?
It's coming from Apache and is correct. ::1 is the same as 127.0.0.1
in IPv6. Which you get will depend on how you request the page and
how your DNS/hosts file is set up. Request it with an IPv6 domain/IP
and REMOTE_ADDR will also be IPv6.
You should be able to disable IPv6 in your system settings, but from
a future-proof point of view you should be able to handle both.
-Stut
This app uses this test to insure that the page being processed
came from the same machine as was used to login to the app. The app
is intended for broad use so I can't control the use of IPv6. Is
localhost the only case where the value returned might have different
values? Can you point to a reference where I might figure out a
better future proof test?
Using the IP is not a reliable way to check for this. Some ISPs use
transparent proxies which can cause each subsequent request to come
from a different IP, regardless of whether it's v4 or v6. You'd be
better off using a cookie, although that would be a bit less secure.
If you really need to use IP then you can probably rely on it not
switching between v4 and v6 if you're not using localhost. For testing
use the machine's real IP or hostname instead of localhost and this
problem should disappear.
-Stut
Thanx, using the real ip addr solved my problem as far as my test
install is concerned. I did do some research and found the text display
conventions for IPv6 ip addresses. But it looks like it would be better
to develop a better test than to make an IPv6 safe one.
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php