Mobile app version of vmapp.org
Login or Join
Si4351233

: How to detect visitor's country from his IP for my PHP website right on the server the problem: I need to detect visitor's country from his IP so I can display specific code based on the

@Si4351233

Posted in: #IpAddress #LookingForAScript #Php #Server #WebDevelopment

the problem:

I need to detect visitor's country from his IP so I can display specific code based on the user location (different ads, etc.) in my PHP website.

There is many different external services such as Ip-api.org which does this, but I want to do it internally on the server (it's faster).

The question:

How to do it? What do I need to install or what do google out?

Update:

Ideally with some open-source licence.

10.01% popularity Vote Up Vote Down


Login to follow query

More posts by @Si4351233

1 Comments

Sorted by latest first Latest Oldest Best

 

@Ravi8258870

dev.maxmind.com/geoip/geoip2/geolite2/
This will give you a database of IP ranges and associated country. You can query this with PHP to find out the country for a given IP address.

Make sure you read the license conditions. You will also need to keep the data updated, as otherwise it will get less accurate over time.

10% popularity Vote Up Vote Down


Back to top | Use Dark Theme