php – Timer server-side?


I'm doing a quiz game in PHP, user will have 15 seconds to answer each question, how to prevent user from changing timer via inspect element and add seconds?

Just adding details, it's not feasible to let the user change the time from 15 to 50 seconds for example and check if the time matches via PHP because I want to implement the game so that 2 users play simultaneously, so the two would have 15 seconds and advance the questions together.


Perhaps you can server-side save the time (timestamp) the question was sent and then compare it to the time the response was sent.

If the difference is less than your limit (with a little fat for network latency issues), you accept the answer. Otherwise (that is, if the difference is greater than acceptable), it does not accept and returns an error.

In this way the client-side counter becomes just a view, but its validation is secure on the server-side.

Scroll to Top