Question

I have a quiz application in which there is a countdown timer of 300 seconds to answer 10 questions and after that scores are sent to server and compared with answers and stored . My problem is when i make a countdown timer client side with javascript , anyone can easily mess up with it, whether i use cookies or use any code , it can be altered by the user . Is there any way to make a safe countdown timer using php so that it cannot be changed by user explicitly. I'm really stuck up in this issue.Thanks in advance !

Was it helpful?

Solution

if user can re-participate Store end time in an session or cookie variable in beginning

if(!isset($_SESSION['endtime']))
$_SESSION['endtime']=strtotime("+300");
else
if($_SESSION['endtime']>strtotime("now")){
//Game over
}
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top