Can anyone give me some pointers on the easy way to access the country data of my users in php? I am running the phpadsnew & maxmind DB at the minute but I would like to be able to access the country data directly from a php script rather than via phpadsnew. The manual says I can set a cookie but I can't figure out what the cookie is doing. Edit: using this, any better ideas? if (isset($_COOKIE["geo"])) { $country = $_COOKIE['geo']; } else { include("geoip.inc"); $gi = geoip_open("GeoIP.dat",GEOIP_STANDARD); $country = geoip_country_code_by_addr($gi, $REMOTE_ADDR); geoip_close($gi); setcookie("geo", $country, time()+432000, "/", ".mad4mobilephones.com", 0); } Code (markup):
I've got it working using the code above. Just seems that I am querying twice for each user. Once for phpadsnew and once for my script. Would be better if I could access whatever cookie phpadsnew is setting from my php script.