[eluser]leighmarble[/eluser]
[quote author="Tpojka" date="1394060354"]Input library is autoloaded so you can use it rather if you don't need session library.[/quote]
Yes, the Input library is autoloaded by CodeIgniter no matter what. But as I mentioned, the website I'm working on also has the Session library autoloaded, which makes the Input method and the Session method equally available in this case.
Really, since I only see advantages to using the Input library method, I'm looking for arguments in favor of using the Session library method.
When would using the Session library method of grabbing the ip_address key from the stored user data ever be the preferable way of getting a user's IP address?
In fact, in CodeIgniter's Session library, it calls the Input library's ip_address() method and, if the ip_address stored in the session doesn't match the value returned from the Input class, it destroys the session. See the Session.php file, lines 185-189 (in CodeIgniter version 2.1.4):
Code:
if ($this->sess_match_ip == TRUE AND $session['ip_address'] != $this->CI->input->ip_address())
{
$this->sess_destroy();
return FALSE;
}
So... as far as I can tell, input->ip_address() always reigns supreme, and using the session method only means extra overhead.
But if there are arguments to the contrary, I would love to hear them, before I abandon the session method of fetching ip addresses forever!