Re: getting the IP address off a visitor
| From: | Kondwani Spike Mkandawire | Date: | Tue, 09 Jul 2002 11:46:46 +0000 |
| Subject: | Re: getting the IP address off a visitor | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-106341@lists.php.net to get a copy of this message | ||
Despite all downfalls of using IP addresses,
if you are in North America most people
in a University or business environment use
a fast connection (DSL or Cable) you may
choose to use the following chunk of code to
retrieve someone's IP number
if (getenv(HTTP_X_FORWARDED_FOR)){
$ip=getenv(HTTP_X_FORWARDED_FOR);
}
else {
$someones = getenv(REMOTE_ADDR);
}
// From Klemens Karssen's code from www.php.net
Alternatively use Cookies which are easy to
use (check the cookie function on www.php.net
Cookies and Sessions from my understanding
of earlier discussions in this forum might be a
wiser idea...
Spike..
"Sebastian Marcu" <sebimarcu@yahoo.com> wrote in message
news:20020704162223.8082.qmail@pb1.pair.com...
> Hi there,
>
> I am new to PHP and need some help.
> I was wondering if there is a way to get hold of the IP address of a site
> visitor with PHP. I'm trying to develop an interaction where the server
> would recognise a new visitor from a returning visitor via the IP address.
>
> Regards,
>
>
> Sebastian
>
>
>
>