I recently had to put together a rating system for some essays at work and I used Fivestar with Voting API. It was quick and easy except everyone at work presents with the same IP address and they are anonymous users so each rating was overwriting the last. (In essence, lots of people were rating but Voting API saw the one IP address and thought it was one anonymous person constantly changing his vote.)
My workaround was to populate the vote_source field with the user's session_id instead of the IP address 'vote_source' => session_id(), and it seems to have the desired effect. It's not perfect (they could open new sessions to enter multiple votes), but it's better than reflecting only the latest vote.
My humble request is to add an option similar to "Differentiate anonymous users by session id". (ex. good for users behind corporate firewalls who all present with the same IP address)
Regards,
Märt
| Comment | File | Size | Author |
|---|---|---|---|
| #16 | votingapi_798790_16_cookie_source_tag.patch | 1.51 KB | itarato |
| #11 | votingapi-sessionid-vote_source-798790-11.patch | 1.68 KB | jemond |
| #7 | votingapi-sessionid-vote_source-798790-7.patch | 3.64 KB | vaartio |
| #6 | votingapi-sessionid-vote_source-798790.patch | 2.04 KB | vaartio |
| #2 | anonymous-voting.patch | 2.22 KB | Stalski |
Comments
Comment #2
Stalski commentedSame issue, here's a patch
Comment #3
swentel commentedSubscribing +1 from me too!
Comment #4
bkosborneAhh I've been looking thru the fivestar/votingapi code for a couple hours now. I was just about to implement something like this. Nice work - will apply the path. This should def be commit.
Comment #5
bkosborneWait a minute.... What is the point of the other option in VotingAPI then? For the time frame before anonymous users can vote again? From what it describes it seems like it should do what we are doing here. But there is only one reference to it in the code and it doesn't make much sense to me... or work for that matter....
Comment #6
vaartio commentedIt looks like votingapi is not using that 'Anonymous vote rollover' feature at all. There's only one reference to it in votingapi_select_votes function but I don't figure out what it should do. I extended Stalski's anonymous-voting.patch a bit and added a checkup to votingapi_set_votes function where I compare votingapi_anonymous_window variable against user's latest vote timestamp. This should prevent voting if vote rollover time has been set up and not passed yet. Here's a patch.
Comment #7
vaartio commentedDidn't include Stalki's votingapi.admin.inc changes into the previous patch. Here's a new one. Sorry.
Comment #8
danny englanderI tried the patch and I now have the session ID validation option which seems to work. I can now visit two different computers from the same range of IP addresses from one router and vote on those individual machines.
I think the only downside to this is if someone clears their browser cache, they can vote again. But I suppose there will always be people who try to game the system no matter what it is. (...and indeed the "Anonymous vote rollover" as mentioned above never really seemed to work either before or after the patch).
Comment #9
Samshel commentedI tried the patch, everything seems to be fine after reviewing the code, but my problem is that session_id() always change on page refresh, which lets the same anonymous user vote unlimited times on the same content.
What I found is that when you are not logged in, the module looks for the session id in the table to see if there is a registry with a vote attached to it, and since everytime that I send the request the session id is changing, no match is found, and so the user can keep voting.
What can be done to prevent this from happening?
Comment #10
lee20 commentedSubscribing. I have the same issue as Samshel. When using the session_id() for the vote_source unlimited votes are being allowed from anonymous users.
Comment #11
jemond commentedUpdated patch for D7 attached.
Comment #12
jemond commentedCross posting for those using the Rate module and this patch:
https://www.drupal.org/node/2324845#comment-9073361
Comment #13
luksakThe patch doesn't create a session for the user. This causes two issues:
How can we open a new session?
Comment #14
luksakComment #15
dragon658 commentedSubscribe. Please add this to the next release of the module, it is very important for some people!
To fix this, I have added
before lines with session_id function.
I know that it is ugly solution. But is works.
Comment #16
itarato commentedI also need the ability to customise the source. However I'd like to keep it as clean (and still flexible) as possible, added a new patch that allows you to create your own vote_source token. Please review.
Comment #17
jibus commentedUsing #11 and Session API module, you will have a session per user.
In votingapi.module, replace session_id() by session_api_get_sid().
Comment #18
pieterdcSession API also works with the patch from comment #16. Just set the Drupal votingapi_source_callback system variable to 'session_api_get_sid', no need to adjust the code of the patch to be able to integrate it with Session API, in contradiction to the patch from #11.
The Drupal variable and the helper function is what I like more about #16.
The admin UI and the lack of PHP constants is what I like more about #11.
Both patches are backwards compatible. That's good.
Comment #19
legolasboDrupal 6 is no longer supported. Closing old issues to clean up the issue queue.
Please reopen and update this issue if this is still an issue in the D7 or D8 version.
Comment #20
tr commentedReading the issue it's clear that it IS a problem in D7 at least, and there are other D7 issues in the Rate and Fivestar modules that are blocked by this:
#2324845: Support storage of votes by session ID as well as IP address
#2631646: anonymous cannot vote
the issue version should have been changed to D7 long ago ...