title: Preventing client side abuse/cheating of repeating Ajax call that rewards users
body: <p>I am working on a coin program to award the members for being on my site. The program I have makes two random numbers and compares them, if they are the same, you get a coin. The problem I have is someone could go in the console and get "free" coins. They could also cheat by opening more tabs or making a program to generate more coins right now which I am trying to stop. I am thinking about converting it over to php from js to stop the cheating (for the most part) but I don't know how to do this. The code in question is:</p>
  
  <pre><code>$.ajax({
      type: 'post',
      url: '/version2.0/coin/coins.php',
      data: {Cid : cs, mode : 'updateCoins'},
      success: function (msg) {
          window.msg=msg;
      }});
  </code></pre>
  
  <p>And the code for the console is that with a loop around it. In the code above, "cs" is the id of the member so by replacing it with their id would cause them to get all the coins they would want.</p>
  
  <p>Should I just have an include with variable above it? But then how would I display the success message which has the current number of coins. Also, this code is in a setInterval function that repeats every 15 milliseconds.</p>