Ok after reading around abit I decided that I will only save the users IP adress when he loggs in and start his logged in session. But here is the thing, I can't use the entire IP as many have dynamic IP's as many know, so I will only save the first 5 digits in the IP as the first numbers usally dont change even if it is dynamic.
So here comes a question about what takes more power. As this will be in a table with maybe many 1000 logged in users at the same I want it to be fast, so is two senerios.
1: I take the ip lets say 52.522.52.52 runs a preg replace to remove the dots(.).
$ip = preg_replace("/[^0-9]/","",$ip);
I do this so I can save the value as a INT instead of a VARCHAR, as I read this is faster when it comes to DB's.
When I now have my value 525225252 I will only take the 5 first digits. As I said the last one's can change alot and give the user a bad browsing experience, with being logged out in the middle of sessions.
So I do a substr()
substr('525225252', 0, 5);
So I end up with the value of 52522, the value of 52522 will then be save in the db with a timer() userid etc.
The the pre_replace and substr will be done on every page view to check so the ip is still the same as it was when the user was logged in.
2: Just save the IP 52.522 as VARCHAR in the DB and just check for the second dot instead and save it as to the DB and compare each page view.
I really hope you understand what I am talking about here hehe, if you have better ideas please share.