HTTP_CF_IPCOUNTRY not found in the header

Hello Members,

I am receiving this error
Undefined index: HTTP_CF_IPCOUNTRY even after activating all options for it at Cloudflare.

  • Added visitor location headers Managed Transform
  • IP Geolocation is activated

Running this below code in PHP not showing HTTP_CF_IPCOUNTRY data.
print_r ($_SERVER)

Please help.
Thank you in advance.

You’re using PHP, correct?

Seems like HTTP_CF_IPCOUNTRY doesn’t exists in the $_SERVER array variable at all :thinking:

Below code works fine for me:

    echo $country_code = $_SERVER["HTTP_CF_IPCOUNTRY"]; 

For testing purpose, I’ve tested among 3 different zones, Free, Pro, Business.
On all of them, I didn’t used Transform Rules.
IP Geolocation feature is enabled at CF dashboard → Network.

However, I did implemented the method to return the real visitor IP when using Cloudflare proxy in my log files:

This topic was automatically closed 15 days after the last reply. New replies are no longer allowed.