Hi Guys, i hope i can get your opinion. I have a site and i setup a geoip. i have a table of given IP range for a given country. Now my question is i setup a small script that display the Country of a certain user. and everytime the user goes to another page (other .php files), i query on the geoip table. So im planning to store the Country information per user log instead of querying the IP looking for the designated country. what do you think is better? Thanks, gigamike
There's no need to query it on each page view, it's a waste of processing time. The IP won't change and the country won't change between clicks (unless they're on a plane, but screw them). I store the results in a session or cookie so even when they come back later, I don't have to query it again.
I also use geo to locate user country, state, city. But, on the first page view, the query will obtain the data and store it in a month long cookie.
You can use sessions instead of cookies and I think will suit better for this purpose. What if someone has cookies disabled? Either you will end up sending a query to the DB again and again or display messages which are not Geo targetted... Bye
All true... For me, I think it's a small percentage of disabled cookie users. Also, I think sessions are best for logins. Some people cant control how long sessions last. So if it were the default 24 minute sessions (I think its 24 min for php), then every time they leave and come back... you know. For this... I say cookies all the way.