This question already has an answer here:
Context
I have a web game in JavaScript.
I send scores and achievements with AJAX during the game.
So anyone can view the source code, copy this request and cheat on my game.
Questions
- Any idea of how prevent this?
- With a token from server (I never used this system)?
Code
$.post('ajax/score.php', {pseudo: $pseudo, score: $score, achiev: $achiev},
function(data) {
$('#loader').show().delay(3000).fadeOut(1000);
}
);
php:
if (isset($_POST['pseudo']) &&
isset($_POST['score']) &&
isset($_POST['achiev'])) {
...
}
As the game is client side, there is no way to ensure that they do not "cheat". There are ways to make it more difficult.
As long as the game is client side, it cannot be "secured".