How to Check Authenticity of an AJAX Request

后端 未结 15 1070
悲&欢浪女
悲&欢浪女 2021-01-31 08:47

I am designing a web site in which users solve puzzles as quickly as they can. JavaScript is used to time each puzzle, and the number of milliseconds is sent to the server via A

15条回答
  •  野性不改
    2021-01-31 09:19

    The way I would do this is that when the server sends the puzzle to the client, the current time is stored in a session. This ensures that the timing starts immediately after the puzzle has been sent. After the puzzle has been completed, and is sent to the server to check if the puzzle was done right, the server again checks the time and does a comparison.

    Obviously slow Internet connections can make this time bigger, but there's nothing you can do about it.

提交回复
热议问题