tags:

views:

139

answers:

2

In writing a login module, I want to log IP's as an additional measure for verifying who's on the other side is still the same person on the other side.

I'm using $_SERVER['REMOTE_ADDR'] as one (of many) ways to get the remote machine's IP address. Aside from an IPv4 or IPv6 address, are there any other values i should expect this to return?

+2  A: 

According to the PHP online documentation only an IP address should be returned.

http://us.php.net/manual/en/reserved.variables.server.php

“'REMOTE_ADDR':

The IP address from which the user is viewing the current page.”

Tim
the problem is that i've read and seen instances where $_SERVER['REMOTE_ADDR'] returns multiple addresses. a quick google search turns up this link: http://www.bigresource.com/PHP-Why-is-_SERVER-REMOTE_ADDR-returning-multiple-IP-Addresses--Mcv258QQ.html
pxl
A: 

There's really no added security to checking IP addresses as these can be easily spoofed and anyone who's savvy enough to be intercepting POST transactions is probably doing this anyways.

Also, you may be potentially annoying legitimate users. Think of the instance where a person may be in a location where there are several free open wifi hotspots. When they get to your login page, they may be connected to one hotspot but by the time they sign in, their machine may have decided another router is a better option and therefore their IP will change. Believe it or not, this may deter some (albeit, very few) easily-frustrated users.

Honestly, I just wouldn't bother. Using SSL, if you can, is usually the best way to go to avoid security issues like the one you're describing. Good luck with your project.

KyleFarris
hey kyle, thanks for your comments. i'm just trying to be thorough when it comes to user information and verifying the proper credentials. And considering things like wifi hotspots and other areas where the user can get annoyed by a false positive are what I want to be thinking about when designing the log-in scheme.
pxl
Excellent. :-) Glad to be of assistance.
KyleFarris