开发者

Using ip address to track visitors, is there a better way? (using Flask micro-framework)

开发者 https://www.devze.com 2023-01-31 08:47 出处:网络
I am going to use Flask micro-framework (based on Werkzeug, and I\'ll be using Python 2.7 or 2.6) to make a games website.

I am going to use Flask micro-framework (based on Werkzeug, and I'll be using Python 2.7 or 2.6) to make a games website.

I want to allow users to vote (simple 1-5 stars) on games, and also to track how many unique visits there have been to each game page - such that I can dynamically order links to the games based on their score/popularity.

Currently I plan on using the client's remote address (via this attribute: http://werkzeug.pocoo.org/documentation/dev/wrappers.html#werkzeug.BaseRequest.remote_addr) to test for uniqueness, by storing all the ip-addresses开发者_StackOverflow社区 that have voted for/visited a game so they cannot vote again, and their visit only gets recorded once.

For the voting: it is important that users don't have to login.

Is this a good way to go about this, what are it's advantages/disadvantages?

Or can you think of a better solution? Are there ways built into the framework to handle these tasks you know of?

Thank you very much for your help, it is very much appreciated :-)

Jonathan


In my opinion using the IP address isn't the correct approach.

  1. Many colleges, campuses, hotels, dorms, and offices use a single or small block IP range. This means that only a single person in one of those environments can vote. So if you have a dorm building with 3,000 kids in it who are all behind a single IP via NAT, only one lucky person gets to vote.
  2. IP Addresses change. Any person that insists on voting more than once can usually power cycle their equipment or go into the management for their router and lease a different IP.

If not logging in is required, I would suggest cookies. Yes - cookies can be cleared, but there are other more permanent ways of storing a cookie if you absolutely must. However, in many cases, I would think a general cookie with an expiration date 10 years in the future works just fine.


Generate a GUID and put in evercookie

0

精彩评论

暂无评论...
验证码 换一张
取 消