How to get client IP address in PHP? Issues with HTTP_X_FORWARDED_FOR and REMOTE_ADDR
Hello everyone! I'm a beginner PHP developer and I've encountered a problem with getting the real IP address of a site visitor.\n\nI'm writing a simple user action logging system. I need to save the IP from which the request came. I use the standard `$_SERVER['REMOTE_ADDR']` variable, but I noticed that it often shows 127.0.0.1 (when testing locally) or my server's address, rather than the real client IP.\n\nHere's the simplified code I'm currently using:\n\n```php\n\n```\n\nI read on forums that I should check `HTTP_X_FORWARDED_FOR` or `HTTP_CLIENT_IP`, but when I tried, I got an empty string or null. Additionally, I've heard that these headers can be spoofed and it's not secure.\n\nPlease advise how to properly