Correct way to store IP Addresses
I'm creating a rating system where the user can only vote once.
Which method is the best to store this ip address.
Should I store it as a serialized array into a longtext field?
Should I store each ip address in a separate table?
Probably each IP should be in a separate row of one DB table (with the IP address field being indexed to make sure searches are as fast as possible).
"Please give us a simple answer, so that we don't have to think, because if we think, we might find answers that don't fit the way we want the world to be."
~ Terry Pratchett in Nation
How to Ask Questions the Smart Way
(not affiliated with this site, but well worth reading)
At first it doesn’t seem that dificult, most people simply store an IP-number as a string in their database tables. It simple and when you have a rather limited amount of addresses a simple VARCHAR 11 wil suit you rather well.
Personaly I think its better to go with second one.
Originally Posted by sc_king
and one more thing if you are concerned in a way that user might vote twice or multiple times unfairly then there is practically no solution other than a login system (which is also not a perfect solution) further various measures could be applied.
Also, what about large groups of people sharing an IP address (such as an office, or campus)? Restricting it to one vote per IP address may cause irritation when you tell people "You've already voted" and they haven't.
Restricting to ip address is a bad way to go many people have dynamic Ips that are always changing there is no real sure fire way to prevent multiple votes unless you are going to require them to register and login then you can go by a user id.
Users Browsing this Thread
There are currently 1 users browsing this thread. (0 members and 1 guests)