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

From: Date: Thu, 18 Sep 2008 14:09:13 +0000
Subject: Re: $_SERVER["REMOTE_ADDR"] returning ::1
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-280441@lists.php.net to get a copy of this message
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 -- http://stut.net/

« previous php.general (#280441) next »