sniffing the IP address

Hello Forum!

I apologize if this has already been asked and answered here.

How do I code my web site so that I can sniff out the IP address of the person visiting the site? I want to then redirect the user according to their IP address. Specifically, if the user is coming from an Arabic or Farsi country state, I want to redirect them to a different page (then if they specifically request to see the content in English, I will remember this by a cookie).

The users IP is stored in the $_SERVER[‘REMOTE_ADDR’] variable.

Thanks. I had no idea it would be so easy. Now I need to code the index accordingly, I assume.

You might want to look at this link. There are ways to fake the standard IP using forwarding, etc.
This page explains how to grab all of the real ones even if forwarded thru a router or proxy.

https://www.virendrachandak.com/techtalk/getting-real-client-ip-address-in-php-2/

(Might be over-kill for your needs…)

Sponsor our Newsletter | Privacy Policy | Terms of Service