How to time a jQuery game with php
<p>I'm creating a jQuery game where the player has to complete a task in the quickest time possible.
I display a timer so the user knows how long they are taking to complete the task.</p>

<p>I've been reading up on cheating/hacking and it seems the only way to prevent it is to keep the important logic server side. My server side language of choice is php.
As the important logic for my game is the time taken, I can set a timer when the game starts, and stop the timer with an ajax call when the game ends.</p>

<p>I'm just wondering what to do if there is a lag between the ajax call being made and the server receiving the call.
Say the user completes the task in 12 seconds but there is a 1 second lag for the ajax caqll to be recieved.
The value written to the highscore table will be 13 seconds which will make for an unhappy player!</p>

<p>Is the server side timer/ajax call the way to go here? Am I worrying too much about a lag? Is there a better way to go about timing a game?</p>

<p>This is my first ever game so I'm unsure about the best way to stop cheating!</p>
