note 5985 modified in function.getenv by irc-html

From: Date: Mon, 21 Jan 2002 00:05:05 +0000
Subject: note 5985 modified in function.getenv by irc-html
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-25585@lists.php.net to get a copy of this message
Get the RIGHT IP adress of the current user When you use REMOTE_ADDR for getting the IP of the current user, sometimes you get the IP of the ISP Cache server. When this happens, the HTTP_X_FORWARDED_FOR is also set, it contains the IP of the user. So with this script, you always get the right IP: if (getenv(HTTP_X_FORWARDED_FOR)){ $ip=getenv(HTTP_X_FORWARDED_FOR); } else { $ip=getenv(REMOTE_ADDR); } For comments please mail me. Klemens Karssen --was-- Get the RIGHT IP adress of the current user When you use REMOTE_ADDR for getting the IP of the current user, sometimes you get the IP of the ISP Cache server. When this happens, the HTTP_X_FORWARDED_FOR is also set, it contains the IP of the user. So with this script, you always get the right IP: <PRE> if (getenv(HTTP_X_FORWARDED_FOR)){ $ip=getenv(HTTP_X_FORWARDED_FOR); } else { $ip=getenv(REMOTE_ADDR); } </PRE> For comments please mail me. Klemens Karssen http://www.php.net/manual/en/function.getenv.php

« previous php.notes (#25585) next »