Re: $_SERVER["REMOTE_ADDR"] returning ::1

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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?

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux