0

I have enabled cloudflare in my website. Now I want to get the visitors country.

I am using this code $_SERVER["HTTP_CF_IPCOUNTRY"] to get current user country. It is returning the correct country in Desktop devices. But it is not returning the correct country on Mobile. I cannot understand how it is possible. It is always returning the Cloudflare enabled country when browse from the mobile.

Any suggestion highly appreciated. I looked into this question already and took the current code from it. But no worth for mobile devices.

Thanks in advance

WP Learner
  • 788
  • 1
  • 13
  • 34

1 Answers1

0

If you are using web browser in mobile device, it is commonly that you are connecting via a proxy server and not directly to web server without user aware of it.

The benefits claimed by web browser that they will compressed the data in the server to speed up your page load time and reducing your mobile data usage.

In this case, CloudFlare could not detect your actual IP address.

You can visit https://www.ipaddress.my to see your IP address from the mobile web browser.

Michael C.
  • 1,410
  • 1
  • 9
  • 20