definitive way to get user ip address php

Php

Php Problem Overview


> Possible Duplicate:
> Function to get user ip address

<?PHP

$ipaddress = $_SERVER["REMOTE_ADDR"];

echo "Your IP is $ipaddress!";

?>

I was told this way of getting ip address has issues such as being able to fool. Is there a better way to gather ip address? looking for tutorials of better way to get ip address?

Php Solutions


Solution 1 - Php

$_SERVER['REMOTE_ADDR'] is the only reliable IP address you'll get - it's extracted directly from the TCP stack and is where the current connection was established from. This means if the user is connecting via a proxy, you'll get the proxy's address, not the user's.

Any of the other header-based ones are unreliable, as HTTP headers are trivial to forge. You can use the information from them, if you'd like, as long as you don't TRUST it.

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
Questionuser62617View Question on Stackoverflow
Solution 1 - PhpMarc BView Answer on Stackoverflow