how to make countdown timer to not reset on page refresh

前端 未结 4 954
无人及你
无人及你 2021-01-27 17:18

I am creating an online exam page for my project. I have a countdown timer, but it resets on page refresh. How can I make it not to reset? The timer is set by fetching time from

4条回答
  •  盖世英雄少女心
    2021-01-27 17:58

    You'll probably need to register a table like active_exams with an examId field and datetimeStarted. Then load the timer as the number of seconds for that exam since it was started.

    You may be able to create some workaround with cookies, localStorage or even the session but keep in mind those will be modifiable (or at least forgettable in the case of the session) by the user.

提交回复
热议问题