Get user country and ip php and Cakephp
Cakephp function to get ip and country of user
public function getUserIpLocation(){
$uinfo['userip'] = $this->request->clientIp();
$userip = $this->request->clientIp();
$details = @json_decode(file_get_contents("http://freegeoip.net/json/".$userip));
$uinfo['usercountry'] = $details->country_name;
if($uinfo['usercountry']=="") { $uinfo['usercountry']="Unknown"; }
return $uinfo;
}
Php Function to get user ip and country
public function getUserIpLocation()
{
$uinfo['userip'] = $_SERVER['REMOTE_ADDR']
$userip = $this->request->clientIp();
$details = @json_decode(file_get_contents("http://freegeoip.net/json/".$userip));
$uinfo['usercountry'] = $details->country_name;
if($uinfo['usercountry']=="") { $uinfo['usercountry']="Unknown"; }
return $uinfo;
}
Comments
Post a Comment