Jump to content


Photo

Cookies or session storing start and end time...


  • Please log in to reply
3 replies to this topic

#1 XeroXer

XeroXer
  • Members
  • PipPipPip
  • Advanced Member
  • 80 posts
  • LocationSweden

Posted 01 August 2006 - 11:12 AM

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...
// XeroXer

#2 onlyican

onlyican
  • Members
  • PipPipPip
  • Advanced Member
  • 921 posts
  • LocationHants - UK

Posted 01 August 2006 - 11:31 AM

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;
Tell me the problem, I will try tell you the solution

#3 XeroXer

XeroXer
  • Members
  • PipPipPip
  • Advanced Member
  • 80 posts
  • LocationSweden

Posted 01 August 2006 - 12:07 PM

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?
// XeroXer

#4 onlyican

onlyican
  • Members
  • PipPipPip
  • Advanced Member
  • 921 posts
  • LocationHants - UK

Posted 01 August 2006 - 06:01 PM

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
Tell me the problem, I will try tell you the solution




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users