Jump to content

Cookies or session storing start and end time...


XeroXer

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...
Link to comment
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;
Link to comment
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?
Link to comment
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
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

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.