Getting user's IP address: input vs session methods |
[eluser]leighmarble[/eluser]
[quote author="InsiteFX" date="1394085851"]If he is using database sessions then it will also mean an extra database query call.[/quote] Actually, it wouldn't be an extra database call. If you're using the database to store session data (in the "ci_sessions" table), even if you do nothing at all with your script, CodeIgniter still grabs the session data out of the table, and stores it in the session object. And so any calls to $this->session->userdata('ip_address') are therefore just pulling the ip address as a property from the session object - not making additional calls to the database. THAT SAID... your point would be another argument AGAINST using the Session class method. I'm still looking for an argument FOR ever using it: Code: $ip = $this->session->userdata('ip_address'); Cool? Tell me, when does it ever make sense to use that call? |
Welcome Guest, Not a member yet? Register Sign In |