3
I am making a game of questions in PHP, the user will have 15 seconds to answer each question, how to prevent the user to change the timer via inspect element and add seconds?
Just adding details, it is impossible to let the user change the time from 15 to 50 seconds for example and check if the time beats via PHP because I want to implement the game so that 2 users play simultaneously, then the two of them would have 15 seconds and go through the questions together.
What is the language on the server? PHP or Node.js? What client-side code do you fear the user will handle? you can show the code you have?
– Sergio
Validating on the server side as well. Do not forget to give a small tolerance to compensate for the delay of the request, after all, if the user changes the timer, the time he spends for this will make a big difference. When sending the question, save the sending time on the server, when processing the answer, see if it took more than twenty seconds, for example.
– Bacco
PS: I spoke twenty as an example, in fact the ideal would be to analyze dynamically the delay of the requests and adjust accordingly, not to facilitate even for those who have a bookmarklet cheat, and not harm those who have a slow link. Or use a more "boring" protocol for this, for example, question and answer via websockets, so time would be controlled only on the server.
– Bacco
Sergio, on the server I will use PHP, I still have no code ready, before I start programming wanted to solve this problem. Bacco, but if I do, nothing prevents the player from changing the available time via element inspection.
– André
What code do you have so far?
– PauloHDSousa