IP Login Authentication

0

I'm creating a PHP application for login authentication:

$phpsessid = 'SID: ".SID."<br>session_id(): ".session_id()."<br>COOKIE: ".$_COOKIE["PHPSESSID"]';
file_put_contents("$ip","$phpsessid");
$m = "localhost/'.$ip.'";
$res = file_get_contents("$m");
$title=@$this->stribet($res,'SID:','<br>');
}

$phpsessid will contain the data, time, IP, account login, time, etc. How do I check an IP at the time of login? For example:

IP=>Conta=>PHPSESSID
    
asked by anonymous 08.03.2014 / 20:24

1 answer

1

Using the proxy server, the IP you will get is the proxy server, not the actual IP address of the user. Example:

$ip = $_SERVER['REMOTE_ADDR'];

But fortunately we can do an additional refinement to get more accurate results. Proxy servers carry a property that stores the original IP in the HTTP header. Example:

echo "Remote addr: " .$_SERVER['REMOTE_ADDR'] . "<br/>";

echo "X Forward: " . $_SERVER['HTTP_X_FORWARDED_FOR'] . "<br/>";

echo "Clien IP: " . $_SERVER['HTTP_CLIENT_IP'] . "<br/>";

At the time of login, the user is compared to the IP.

    
08.03.2014 / 20:55