bdaz
bdaz

Reputation: 163

How do you prevent a user from editing values in javascript

Say I have a JavaScript game and i want to upload the persons high score to my database to have a leaderbord or highscores. How would you prevent a user from cheating and manually changing the score value in JavaScript before I save the score in the database?

Upvotes: 0

Views: 1282

Answers (2)

greut
greut

Reputation: 4373

One way I would do it is to send all user actions to your server, in real time or within the final value. This way you can compute the score based on that server side and validate it. I'm assuming you've got a way to simulate a game based on the actions log.

Upvotes: 2

NotABlueWhale
NotABlueWhale

Reputation: 795

Javascript is executed in a user's browser, therefore there is no way to prevent the user from tampering with your code. Use a server-side programming language to manage the score.

Upvotes: 2

Related Questions