Page 1 of 1
Unique likes
Posted: Tue Apr 07, 2015 4:00 pm
by justas28
Looking for a little php help. I am currently developing a page not too different from 9gag. The idea behind it is that each unique visitor has an opportunity to "like" some kind of photo, video, etc. This "liking" thing has to be accessible not only to members, but also to those who are not registered. Each "vote or like" needs to be unique. I thought about having a table in my database matching every possible post "liked" with an ip address, so that every time a visitor opens a site, the script would find out what did he "like". Of course that would require iterating through every data entry in that table, so it is bugging me, whether it's a good approach. Is it?
Re: Unique likes
Posted: Tue Apr 07, 2015 4:08 pm
by justas28
Sorry, if it's not advanced enough of a question, just didn't know where else to ask
Re: Unique likes
Posted: Tue Apr 07, 2015 7:28 pm
by Celauran
You could use indices on IP and story ID to make the lookup trivial. Doesn't solve the problem of one IP not necessarily equaling one user.
Re: Unique likes
Posted: Wed Apr 08, 2015 10:24 am
by justas28
Thanks for your answer. Is there some kind of unique machine id, to identify different pcs under the same ip address?
Re: Unique likes
Posted: Wed Apr 08, 2015 10:33 am
by Celauran
You can use something like browser fingerprinting, which is kinda shady but will probably do what you're looking for. Much like one IP doesn't imply one user, neither does one computer necessarily mean one user.
This "liking" thing has to be accessible not only to members, but also to those who are not registered. Each "vote or like" needs to be unique.
You can have one or the other, but not both. Not reliably.
Re: Unique likes
Posted: Wed Apr 08, 2015 10:37 am
by justas28
I did some googling on the whole subject. I guess it would be smarter to just stick to an IP address. It seems to be either impossible or too much of a hustle for a 9gag site.
Re: Unique likes
Posted: Wed Apr 08, 2015 10:48 am
by justas28
Can I use simple cookies to store arrays of what sort of posts each visitor liked? Would that help?
Re: Unique likes
Posted: Wed Apr 08, 2015 11:02 am
by Celauran
No. Cookies can be cleared by the user.
Re: Unique likes
Posted: Wed Apr 08, 2015 11:36 pm
by Christopher
Celauran wrote:You can use something like browser fingerprinting, which is kinda shady but will probably do what you're looking for. Much like one IP doesn't imply one user, neither does one computer necessarily mean one user.
You could pretty easily create a hash from the browser string and save it with the IP address. That would provide a little more identification of the computer, but not that much.