PHP Developers Network

A community of PHP developers offering assistance, advice, discussion, and friendship.
 
Loading
It is currently Sun May 28, 2017 11:28 am

All times are UTC - 5 hours




Post new topic Reply to topic  [ 9 posts ] 
Author Message
 Post subject: Unique likes
PostPosted: Tue Apr 07, 2015 4:00 pm 
Offline
Forum Newbie

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


Top
 Profile  
 
 Post subject: Re: Unique likes
PostPosted: Tue Apr 07, 2015 4:08 pm 
Offline
Forum Newbie

Joined: Tue Apr 07, 2015 3:57 pm
Posts: 5
Sorry, if it's not advanced enough of a question, just didn't know where else to ask


Top
 Profile  
 
 Post subject: Re: Unique likes
PostPosted: Tue Apr 07, 2015 7:28 pm 
Offline
Moderator
User avatar

Joined: Tue Nov 09, 2010 3:39 pm
Posts: 6243
Location: Montreal, Canada
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.

_________________
Supported PHP versions No longer supported versions


Top
 Profile  
 
 Post subject: Re: Unique likes
PostPosted: Wed Apr 08, 2015 10:24 am 
Offline
Forum Newbie

Joined: Tue Apr 07, 2015 3:57 pm
Posts: 5
Thanks for your answer. Is there some kind of unique machine id, to identify different pcs under the same ip address?


Top
 Profile  
 
 Post subject: Re: Unique likes
PostPosted: Wed Apr 08, 2015 10:33 am 
Offline
Moderator
User avatar

Joined: Tue Nov 09, 2010 3:39 pm
Posts: 6243
Location: Montreal, Canada
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.

Quote:
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.

_________________
Supported PHP versions No longer supported versions


Top
 Profile  
 
 Post subject: Re: Unique likes
PostPosted: Wed Apr 08, 2015 10:37 am 
Offline
Forum Newbie

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


Top
 Profile  
 
 Post subject: Re: Unique likes
PostPosted: Wed Apr 08, 2015 10:48 am 
Offline
Forum Newbie

Joined: Tue Apr 07, 2015 3:57 pm
Posts: 5
Can I use simple cookies to store arrays of what sort of posts each visitor liked? Would that help?


Top
 Profile  
 
 Post subject: Re: Unique likes
PostPosted: Wed Apr 08, 2015 11:02 am 
Offline
Moderator
User avatar

Joined: Tue Nov 09, 2010 3:39 pm
Posts: 6243
Location: Montreal, Canada
No. Cookies can be cleared by the user.

_________________
Supported PHP versions No longer supported versions


Top
 Profile  
 
 Post subject: Re: Unique likes
PostPosted: Wed Apr 08, 2015 11:36 pm 
Offline
Site Administrator
User avatar

Joined: Wed Aug 25, 2004 7:54 pm
Posts: 13396
Location: New York, NY, US
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)


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 9 posts ] 

All times are UTC - 5 hours


Who is online

Users browsing this forum: No registered users and 4 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Jump to:  
Powered by phpBB® Forum Software © phpBB Group