Ways to prevent repeated voting on the Internet (II.)

Source: Internet
Author: User
Tags mdb database variables variable time limit
Voting | Repeat method Two: Use the cookie object
Because the cookie object keeps the value of the variable in the browser client, it can be judged by the isvoted value of the cookie to determine whether the user has voted. Cookies and session variables are private, but if we define the lifetime of a cookie variable, the cookie variable is public, and any user who logs on from the same machine will not be able to vote when the specified time limit is not reached, This, to a certain extent, prevents repeated voting. The implementation process is shown in Figure 2:




According to the actual situation, set the length of the lifetime of the cookie variable reasonably, for example, set to 10 minutes, such a machine can only vote 144 tickets for a single day.

Vulnerability to this approach: in a Windows 9x environment, you can repeatedly vote if you delete all *.txt files in the Windows\Cookies directory. In order to prevent again and again repeatedly vote, below gives method three.

Method Three: Verify IP address and logon time
This method first uses Request.ServerVariables (REMOTE_ADDR) to obtain the user's IP address. Create a standard MDB-type database on the Web server side with a table with only two fields: IP address and logon time. The reason for setting the logon time this field is to consider that dial-up Internet users may share the same IP address, if an IP address can only vote once, then obviously unreasonable. At the same time, we also use the same idea of method two, must be every other set period, the same IP address to vote again. So this method is much stricter than method one and method two in preventing repeated voting. The program flow of its implementation is shown in Figure 3:




Method IV: Small Area Survey
This method only applies to the small scope survey, the idea and the method three identical, only then replaces the IP address in the method three to be possible only to represent the user the field, like student ID number, work permit number and so on. The MDB database was created with only two fields: Certificate number and isvoted (where isvoted is a logical field, true indicates that a ticket has been cast, false indicates that no vote has been made, and the isvoted value of all records in the library is set to false). Before voting, ask to enter the correct ID number, and then judge the value of isvoted. The program flow that implements this method is shown in Figure 4:




From method one to method four, security is more and more high, and the function of repeating continuous voting is more and more strong, but each method has its own limitation. In the application, the user should choose the appropriate method according to the actual situation. If a small range of votes, method four is undoubtedly the best; If you vote on the Internet, method three is the best. Another point that must be mentioned is that although application has the function of saving variables, we do not use them. Because the application variable is a global variable, if the isvoted is set to true with application, no user can vote, and if the isvoted is set to false with application, any user may vote. There is no defensive function.



Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.