Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

vandan's avatar
Level 13

countdown timer create in laravel using session ?

how to create timer countdown using session in laravel

0 likes
3 replies
bobbybouwmann's avatar

What have you tried so far?

The only thing you have to do is store the date you want to countdown to in the session. Then you can do checks against that.

vandan's avatar
Level 13

i am working on project which has question that expires in specified time so how to implement that in such a way that even if the user refresh the page or press the back button the timer should go on.

thanks

clevonnoel's avatar

Here is an example:

$count = 900; //how  much seconds to remember the questions
 
$question = Cache::remember('users:1:question', $counter, function () {
    return  Question::randomQuestion(); /// replace this to get the question
});

For more details see Laravel Cache

if the question is answered clear cache

Please or to participate in this conversation.