Skip to content Skip to sidebar Skip to footer
Reading Time: < 1 minute

PHP get visitor details without any third party web site registrations or keys.Get visitor IP address,region,latitude,longitude,Country,visitor map with php.Look at this example you can get visitor all details even latitude,longitude and country details.

First you must create a folder named “cache” and put folder permission as 0777.

// Get visitor IP address
// remember chmod 0777 for folder 'cache' folder
$file = "cache/".$ip;
if(!file_exists($file)) {
    // request as jason
    $json = file_get_contents("".$ip."&full=true");
    $f = fopen($file,"w+");
} else {
    $json = file_get_contents($file);
$json = json_decode($json,true);
print_r($json); // Array

Display results;

echo $location['countryName']; // Country
echo $location['latitude']  // Latitude

View Demo Visitor details