X

Tracking your visitors' location with PHP

If you are in a situation that you need to show different content to your visitors depending on their location, an easy way to do it is with #PHP using MaxMind's IP database. MaxMind is offering commercial database of locations for IP addresses, but they also have a free product GeoLite Country http://bit.ly/yoPj7C

It is a downloadable data file (MaxMind provides monthly updates) that you can query through PHP or other languages or even an Apache module (MaxMind offers libraries http://bit.ly/yMsTP8 for several languages). If you don't like the idea of downloading a file every month there are other alternatives like GeoPlugin.com and IpInfoDB.com but I opted to skip the part of making network requests to a third-party server.

I've cooked up an example of querying the the data file and keeping the information on a cookie so that the total number of queries is smaller. Check it out here http://bit.ly/wBm7bm

Markos Giannopoulos:
Related Post