Portal Home > Knowledgebase > Articles Database > [PHP]Where or how to get the visitor's City?


[PHP]Where or how to get the visitor's City?




Posted by jagarco, 06-12-2010, 09:18 PM
Hi Ok, I know there are sites that gives you some outsourced code or scripts to get the visitors location data. But I only need to know when visitors are local(from my City), so, I really don't care for the rest of the Country/world. This is because I need our website to display different info to local visitors. So, I guess I only need like a list of IP ranges of my city ain't I? Or does PHP have a native function that gives the City location for a given IP? Something like: $city= iplocation('city','100.100.100.100') Does this simple option even exist? Are the IP location database available somewhere? open source? Thank you Giorgio

Posted by petteyg359, 06-12-2010, 11:00 PM
Try GeoLite City. There is a PEAR library and a PECL extension available, also.

Posted by jagarco, 06-12-2010, 11:44 PM
thank you very interesting... They have a web service plan of 50000 queries for 20usd I suppose if I develop a simple cookie validation, a visitor will generate a Query to the remote DB only if the city cookie is non existent.

Posted by petteyg359, 06-12-2010, 11:48 PM
Why not just install the DB on your own system for 0 USD per month?

Posted by jagarco, 06-13-2010, 12:10 AM
By 0.00/month you mean to just get the free version database file? Haven't checked it well but, they offer a free version DB but less accurate than the paid version. I'm checking that for my country accuracy it is supposedly to be... 60%(67%) Free 77%(78%) Paid (almost 400usd) I think that ~15% accuracy is kind of important. Doesn't worth it for 370usd + 90usd/m but I found the Web Service with 50000 queries for 20usd which I think are for the more accurate and already auto-updated DB version, I still need to confirm. So, wouldn't it be better? ~15% more accurate and no manual updating.? Maybe I'm still missing something.

Posted by petteyg359, 06-13-2010, 12:57 AM
If by manual update you mean setting up a simple wget cron job... If $20 is worth 17% extra theoretical accuracy to you... Considering their paid version thinks I'm 100 miles from where I am, I don't think their accuracy is worth money.

Posted by jagarco, 06-13-2010, 01:27 AM
I have an idea of what wget does but don't know exactly how where or what is needed in order to use it, not interested for now as there is only time left for just specific research. Key here is accuracy, not sure yet how to interpret the accuracy they say it has. You say 100miles and I'm still not sure if that is enough or not for my purpose, even if it is free. I need to show specific costs/products locally, and other costs/products for the rest. I was thinking to avoid the need for visitors to manually indicate their location. This aproach is "easy" to implement and 100% accurate but very unfriendly for user experience and some SEO, yes I know they could lie about it but then is their fault and not ours..., unless we do it automatically and with errors(inaccurate), I wouldn't like to cancel their order, tell them our website was mistaken and the right price for them is N usd more, not very good. So then again, I would need to check what kind or how their accuracy works and what does it mean for our purposes.



Was this answer helpful?

Add to Favourites Add to Favourites    Print this Article Print this Article

Also Read
No more cronjobs (Views: 483)
question (Views: 517)
Support. (Views: 507)