简体   繁体   中英

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?

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.

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM