I have a PHP script where I'd like to detect if the user is running on a local machine, not accessible over the Internet. Currently I check for the server address to he 127.0.0.1. Is this the best practice or is there a better way?
Localhost always translates to the loopback IP address 127.0.0.1
in IPv4, or ::1
in IPv6, So validating the IP Within your application would be secure, if you mean
if(IPAddress::In(array("127.0.0.1","::1")))
{
//Show Application
}
I Very much doubt that you will have a team of elite hackers after your port 80 but as a side note there has been some talk about flaws in relying on an IP address as TCP Packets can be modified.
But that should not be a worry for you.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With