Hi,
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?
Printable View
Hi,
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).
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.
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.