Real IP address?

From: Date: Sat, 05 Aug 2000 02:49:02 +0000
Subject: Real IP address?
Groups: php.general 
Request: Send a blank email to php-general+get-10230@lists.php.net to get a copy of this message
I'm trying to get the IP address of a visitor. So far: $REMOTE_ADDR isn't smart to use because x.php?REMOTE_ADDR=1 will result 1 instead of the IP address. getenv("REMOTE_ADDR") is much better, but if the user uses an proxy server it will report the IP address of that server, not the client. according to http://www.php.net/manual/function.getenv.php if (getenv("HTTP_X_FORWARDED_FOR")) { $ip=getenv("HTTP_X_FORWARDED_FOR"); } else { $ip=getenv("REMOTE_ADDR"); } should solve this problem, but I noticed that in my case it doesn't. My IP address can not be found in HTTP_X_FORWARDED_FOR, but in HTTP_CLIENT_IP. This variable thus might be proxy server specific? Has anyone found a better (=working) way to determine the IP address of a client?

« previous php.general (#10230) next »