1

I am looking for some ideas on what i should look at deal with a countdown that when a button is pressed it should start a 2 minute countdown that in anyway can't be skipped. The user should be forced to view the countdown on the site untill it's done. I guess i would need to look at applying a session on the buttonclick and somehow start a countdown when the session is active. What im struggeling with finding out is how to connect all this and what i should look at.

Im not intresting any anyone writing this code for me, please point me in what direction i should focus on and what is important! Thanks.

Emoless96
  • 103
  • 10
  • 1
    this question might be interesting : https://stackoverflow.com/questions/20618355/the-simplest-possible-javascript-countdown-timer – niceman Dec 06 '17 at 18:45
  • And you can use event onbeforeunload to alert the user that you have a timer. https://stackoverflow.com/questions/15769514/window-onclose-function – Marco Dec 06 '17 at 18:51
  • Is something supposed to happen as soon as the countdown finishes, or is it just supposed to block other user actions until it finishes and then wait for some other input? – Don't Panic Dec 06 '17 at 18:58
  • @Don'tPanic It is supposed to update a sql database from the php so i guess some call of action, or just load get back to the page where the user clicked on the button and il update the database from the button click instead of when the countdown is done. – Emoless96 Dec 06 '17 at 19:31
  • Break it down into steps: make the button count down, make something happen at the end of it, figure out how to identify the user so you can check their individual countdown, then figure out how to store the button's countdown (or better yet the time it started counting down + do math to check the current timestamp against it) to be able to check if/when it's done. – HB- Dec 06 '17 at 19:39
  • Your reasonable storage options are $_SESSION, $_COOKIE, and a database entry with a login system to identify which entry goes to which user (which could be overkill for just the one value, but is [less editable than a cookie](https://www.lifehacker.com.au/2015/01/edit-or-delete-individual-cookies-using-chromes-developer-tools/) and [more persistent than a session](https://stackoverflow.com/questions/3684620/is-possible-to-keep-session-even-after-the-browser-is-closed)). – HB- Dec 06 '17 at 19:39

0 Answers0