Unique likes

Not for 'how-to' coding questions but PHP theory instead, this forum is here for those of us who wish to learn about design aspects of programming with PHP.

Moderator: General Moderators

Post Reply
justas28
Forum Newbie
Posts: 5
Joined: Tue Apr 07, 2015 3:57 pm

Unique likes

Post 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?
justas28
Forum Newbie
Posts: 5
Joined: Tue Apr 07, 2015 3:57 pm

Re: Unique likes

Post by justas28 »

Sorry, if it's not advanced enough of a question, just didn't know where else to ask
User avatar
Celauran
Moderator
Posts: 6427
Joined: Tue Nov 09, 2010 2:39 pm
Location: Montreal, Canada

Re: Unique likes

Post 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.
justas28
Forum Newbie
Posts: 5
Joined: Tue Apr 07, 2015 3:57 pm

Re: Unique likes

Post by justas28 »

Thanks for your answer. Is there some kind of unique machine id, to identify different pcs under the same ip address?
User avatar
Celauran
Moderator
Posts: 6427
Joined: Tue Nov 09, 2010 2:39 pm
Location: Montreal, Canada

Re: Unique likes

Post 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.
justas28
Forum Newbie
Posts: 5
Joined: Tue Apr 07, 2015 3:57 pm

Re: Unique likes

Post 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.
justas28
Forum Newbie
Posts: 5
Joined: Tue Apr 07, 2015 3:57 pm

Re: Unique likes

Post by justas28 »

Can I use simple cookies to store arrays of what sort of posts each visitor liked? Would that help?
User avatar
Celauran
Moderator
Posts: 6427
Joined: Tue Nov 09, 2010 2:39 pm
Location: Montreal, Canada

Re: Unique likes

Post by Celauran »

No. Cookies can be cleared by the user.
User avatar
Christopher
Site Administrator
Posts: 13596
Joined: Wed Aug 25, 2004 7:54 pm
Location: New York, NY, US

Re: Unique likes

Post 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.
(#10850)
Post Reply