Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8449521
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T10:43:54+00:00 2026-06-10T10:43:54+00:00

I recently created a website that has a voting/upvoting feature that uses jQuery’s AJAX

  • 0

I recently created a website that has a voting/upvoting feature that uses jQuery’s AJAX functions. The catch is: anyone can vote. I don’t require visitors to be logged in, I don’t track their IP, and I don’t even store a long-term cookie. Normally (don’t laugh), when a user votes on something, I store the ID of the item they vote for in a JavaScript array. Whenever they try to vote, the script checks if they have voted for the given item recently by checking the array for the ID. If they have, it just gives them an alert dialog. Otherwise, it casts a vote. So it goes without saying that all a user has to do to vote again is refresh the page.

I decided to see what happens if I injected some JavaScript (in the URL bar or a web console), and I wasn’t really surprised to find out that voting as many times as you want very rapidly is as easy as:

for (var i = 0; i < 100; i++) { vote(itemID); }

(and that’s being nice). I’m not sure why the array isn’t stopping it, but that doesn’t matter; it will always be easy to exploit this, right? I mean – you could even write a little HTML document with some JS that calls the voting page on my website as many times as you want.

So I want to fix this without too much trouble. Is it possible to create an immutable variable in JavaScript? A constant (though it would really help if there was such thing as a constant that could be changed only once)? The easiest way to fix this to some degree would be to keep the ID-holding array semi-constant: can’t be deleted, but can be added to. Any suggestions or solutions or explanations are greatly appreciated.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-10T10:43:56+00:00Added an answer on June 10, 2026 at 10:43 am

    No, if the users want to cheat by messing with their client-side code, they can do that. This is just like cheat patches for games.

    What you are doing now is very reasonable to avoid accidental duplicate votes, if you feel that this is not enough (for example if the votes are really important), you need to take measures on the server-side. Tracking IP or setting cookies also won’t work, this relies on client-side cooperation as well. You’d have to authenticate the users and mave sure everyone votes only once by storing something in your database.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I recently created a advanced form with elements that use jquery's $().hide & $().show
Has anyone else encountered the problem that jquery-1.6.2.min.js does not at all seem to
I have recently created a directory for a customer of mine. The website is
I recently created a new header file that I want to include in the
I recently created a class which has a constructor taking 3 enumerations as arguments.
I recently created a generic Matrix<T> class that acts as a wrapper around a
I recently created a function in javascript that takes in a file name and
I recently created a ajax based instant messaging application and after running for a
I recently created a WCF service that works fine when tested from Visual Studio
I recently just created a website for a company, http://visionaryminds.com/ , For the most

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.