What's the easiest way to detect the visitor country via IP address? What's the common and recommended approach to solve this problem?
Asked
Active
Viewed 2,817 times
-2
-
There's only one way to detect the country via the IP address: Look it up in a database. The only questions are which one to use (that would be a product recommendation which is off-topic for Stackoverflow) and if it should be hosted or local (and there are pros and cons so its something of a matter of opinion / dependant on circumstance). – Quentin Dec 27 '13 at 18:40
-
working example: http://stackoverflow.com/questions/12553160/getting-visitors-country-from-their-ip – kasper Taeymans Dec 27 '13 at 18:40
-
I only need to know if the visitor from specific country, how many ip address shall detect then? – simo Dec 27 '13 at 19:11
2 Answers
0
You could you use HTML5 Geolocation to detect a users location. There are loads of API already built for you to take advantage off.
Some developers use this change the language of their site to suit the location of the user. Ie. The site is in English, but the visitor is in Ukraine. The site, if the developer has permitted so, the text would translate to Ukrainian without having to let the browser do it.
-1
I do not know the common approach... but i think that sticking to php.net will be fine.

Goikiu
- 574
- 3
- 12