Skip to main content
saps101
Known Participant
June 17, 2010
Answered

php get user country

  • June 17, 2010
  • 2 replies
  • 2313 views

Hi, I'm on multi language website and I need to set the language session by the user country.

It is possible ?

This topic has been closed for replies.
Correct answer

You can use GeoIP PECL extension of PHP:

http://jp2.php.net/geoip

It uses MaxMind's free GeoLite database which is over 99% accurate:

http://www.maxmind.com/app/geolitecountry

2 replies

Correct answer
June 23, 2010

You can use GeoIP PECL extension of PHP:

http://jp2.php.net/geoip

It uses MaxMind's free GeoLite database which is over 99% accurate:

http://www.maxmind.com/app/geolitecountry

saps101
saps101Author
Known Participant
June 25, 2010

Thankyou very much !!!

June 17, 2010

Do a Google on IP addresses. You will find references to databases that will translate IP addresses into locations, city/country/latitude/longitude/postal code/area code. Some are free, others charge a fee. Accuracy is variable, with the more you pay the better the results. Some rates varied with the number of lookups/month.

At least one database offers tables that can be downloaded for free and then uploaded into your own database. Remember, though, you will be dealing with tables that contain roughly 4 million records. Not to mention the need to check of updates regularly for newly defined IP block assignments.