3

In the past I used

$ip = $_SERVER["REMOTE_ADDR"];

Which would return the client's IP. I've recently started hosting my site with Heroku, and I found that the above code no longer returns the client IP.

Has anyone come across this? How would I use PHP to obtain the real IP address of the client if my site is hosted with Heroku?

Allen S
  • 3,471
  • 4
  • 34
  • 46

1 Answers1

5
$ip = $_SERVER["HTTP_X_FORWARDED_FOR"]; 

This link might be helpful.

Community
  • 1
  • 1
chanchal118
  • 3,551
  • 2
  • 26
  • 52