Jump to content

Getting user IPs


Gingetsuryuu

Recommended Posts

I've found out my pc has two ips, one that is common for all adsl users in south africa, and one to uniquely identify each of us, on my site I use $_SERVER['REMOTE_ADDR'] to obtain the ip of the user browsing, but with adsl users from south africa it shows the ip thats common for everyone, and that seriously messes some stuff up. Is there a way to get the other ip or something?

Modify: Here's the ip, this forum gets it too. 198.54.202.66
Link to comment
https://forums.phpfreaks.com/topic/26250-getting-user-ips/
Share on other sites

Well, I live in a screwed up country kinda :p

Anyway, i got it figured.

$headers = apache_request_headers();
$hostname = $headers['X-Forwarded-For'];

would make hostname my real ip, but thats only if the X-Forwarded-For thingey exists. Otherwise a person would have to use the plain old
$hostname = $_SERVER["REMOTE_ADDR"];

Yay for random code testing :p

Link to comment
https://forums.phpfreaks.com/topic/26250-getting-user-ips/#findComment-120079
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.