Re: Problem with REMOTE_ADDR
| From: | Kevin Stone | Date: | Mon, 16 Sep 2002 22:51:24 +0000 |
| Subject: | Re: Problem with REMOTE_ADDR | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-116574@lists.php.net to get a copy of this message | ||
$REMOTE_ADDR is not necessarily going to be the user.. as previously stated
quite often users are behind a router in which case $REMOTE_ADDR is going to
contain the IP of the Proxy server. $HTTP_X_FORWARDED_FOR will only work if
the Proxy sends it which most do not.
The only solution is to use Sessions or Cookies to distinguish users behind
identical IPs.
-Kevin
----- Original Message -----
From: "Kevin S. Dome" <kevin@icefantum.net>
To: "Leif K-Brooks" <eurleif@buyer-brokerage.com>
Cc: "Chris Cook" <cjc1800@hotmail.com>; <php-general@lists.php.net>
Sent: Monday, September 16, 2002 4:36 PM
Subject: Re: [PHP] Problem with REMOTE_ADDR
> This is the string I use to display a user their ip address, I am not sure
> if this is what you are looking for but I figured I would drop my 2 cents
> in.
>
> <?php echo $_SERVER['REMOTE_ADDR']?>
>
>
>
>
>
>
>
> On Mon, 16 Sep 2002, Leif K-Brooks wrote:
>
> > Have you tried a web site such as www.getmyipaddress.com to see if it's
> > on your end or your script's?
> >
> > Chris Cook wrote:
> >
> > > Hello all,
> > >
> > > Whenever I use REMOTE_ADDR, it gives me the IP of the server. Of
> > > course, I am not interested in this and want the IP of the client. I
> > > put this code in to resolve it and it still didnt work. What am I
> > > doing wrong?
> > >
> > > Thanks for any help in advance,
> > > Chris
> > >
> > > if (getenv(HTTP_X_FORWARDED_FOR)) {
> > > $ip = getenv('HTTP_X_FORWARD_FOR');
> > > $host = gethostbyaddr($ip);
> > > } else {
> > > $ip = getenv('REMOTE_ADDR');
> > > $host = gethostbyaddr($ip);
> > > }
> > >
> > >
> > >
> > > _________________________________________________________________
> > > Send and receive Hotmail on your mobile device:
> > > http://mobile.msn.com
> > >
> > >
> >
> >
> >
> >
>
> --
> -------------
> Kevin S. Dome
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>