I’m developing a script for technical quiz which is going to have MCQ types questions (1 question at a time). I want to set time out of 20 mins to each user. After twenty minutes the user should be signed out. The page is going to be reloaded for every new question.
Should I set timeout in PHP or JavaScript? How can I set timeout to to do particular task?
I also want to show the time remaining, and decrease it every second.
Make a cookie named loggedin. PHP code:
setcookie("loggedin", $username, time()+1200);Then check if
$_COOKIE["loggedin"]is set. If not, then user is not logged in.Edit: look at this, it gives some basic recommandations which you could follow with some extra javascript and ajax code
Edit2: perhaps you could try an IP-based solution, but some internet providers could cause problem: as far as I know, some change IP very frequently. If you use this, MySQL is required as well.