I would like to put the 1/1000 second when a button is clicked into a session variable – $_SESSION['Click'] or $_COOKIE['Click']
echo '<a href="index.php?level=done"><img src="./cat.jpg" width="'.$imgwidth.'" height="'.$imgwidth.'"></a>';
The site is called again and the new level is built.
The 1/1000 second when the level is built shall be stored in another session variable $_SESSION['Begin']
Then $_SESSION['TimeNotMeasured'] += $_SESSION['Begin'] - $_SESSION['Click'] or $_COOKIE['CLick']
What would be the solution to get and store the exact time of click?
I finished the Game and it works – but I need a much better solution to measure the time between the moment when the level is finished and the milliseconds or seconds until the next level is built and ready.
2
Answers
Easier than I thought / Made a tested and working Solution:
You’re talking about things that happen in the browser:
You therefore have to measure these things in the browser, not in PHP. You could for instance use performance.now(), like so:
After you’ve timed it you can send the information back to the server, with a delay and store it there.