$_SERVER[“REMOTE_ADDR”] gives server IP rather than visitor IP

后端 未结 8 736
小蘑菇
小蘑菇 2020-11-28 05:55

I\'m trying to track IP addresses of visitors. When using $_SERVER[\"REMOTE_ADDR\"], I get the server\'s IP address rather than the visitor\'s. I tried this on

相关标签:
8条回答
  • 2020-11-28 06:28

    Try this

    $_SERVER['HTTP_CF_CONNECTING_IP'];
    

    instead of

    $_SERVER["REMOTE_ADDR"];
    
    0 讨论(0)
  • 2020-11-28 06:30

    When using $_SERVER["REMOTE_ADDR"], I get the server's IP address rather than the visitor's.

    Then something is wrong, or odd, with your configuration.

    • Are you using some sort of reverse proxy? In that case, @simshaun's suggestion may work.

    • Do you have anything else out of the ordinary in your web server config?

    • Can you show the PHP code you are using?

    • Can you show what the address looks like. Is it a local one, or a Internet address?

    0 讨论(0)
提交回复
热议问题