Jump to content

Archived

This topic is now archived and is closed to further replies.

XeroXer

Cookies or session storing start and end time...

Recommended Posts

I have a quiz on my site where people can go through a series of question answearing what they think.
Now I want to add a timer so in the end they can see how long time it took for them to answear it all.
I use just one file for this and use case 1: break; and so on.

Now I want to know the best secure way to store the start time and endtime and also print it into a file.
Because in the end of the test they can enter their name and a small message and they end up in the highscore. :-)

Is there a way to do this so if the time is stored from the start and then I can store another one in the end and show the start and endtime to the people.

If you don't undertsand what I mean say so and maybe I can explain better...

Share this post


Link to post
Share on other sites
Sessions:
Good = If the user has cookies turn off they still work;
Bad = They expire when the browser is closed, or after a short while (Set in php_ini);

Cookies:
Good: They have a longer shell life;
Bad: If the user has cookies turned off, tough;

Share this post


Link to post
Share on other sites
Ok. Can I somehow use them both for the best preformance?
Or maybe test with cookies toi see if the user has them turned off and then use session?

Then also how would I use them to get the current date and time into a cookie or session and how do I read it out of them the best way?

Share this post


Link to post
Share on other sites
The thing with cookies is when you set a cookie, you need to reload the page to check the value
If you just want to store a date/time a session will do the job
$_SESSION["start_time"] = date("Y-m-d H:i:s");
Or what ever format you want

Share this post


Link to post
Share on other sites

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.