What is a reliable method to record votes from anonymous users, without allowing duplicates

前端 未结 8 1974
广开言路
广开言路 2021-01-30 11:16

First of all, I searched as best I could and read all SO questions that seem relevant, but nothing specifically answered this. This is not a duplicate, afaik.

Obviously

8条回答
  •  野的像风
    2021-01-30 11:26

    The simplest answer is to use a cookie. Obviously it's vulnerable to people clearing their cookies, but anonymous voting is inherently approximate anyway.

    In practice, unless the topic being voted on is in some way controversial or inflammatory, people aren't going to have a motive behind rigging the vote anyway.

    IP is more 'reliable' but will produce an unacceptably high level of collisions due to NATs.

    How about a more unique identifier composed of IP + user-agent (maybe a hash)? That effectively means for each IP, each exact OS/browser version pair gets 1 vote, which is a lot closer to 1 vote per person. Most browsers provide detailed version information in the user-agent -- I'm not sure, but my gut feel is that this would prevent the majority of collisions caused by NATs.

    The only place that would still produce lots of collisions is a corporate environment with a standardised network, where everyone is using an identical machine.

提交回复
热议问题