0

I need to find a way to store users data that they have input into a form. It will be triggered by the user clicking a "save" button. At which point all of the data that they have input will be stored. When the user returns to the form they should be able to see their data in order to complete the rest of the form in order to submit the information. I want this data to be stored for 24 hours only after which point they will lose the data that they have already input.

If anybody has a method or any advice I will be grateful.

Matt Ginn
  • 294
  • 1
  • 2
  • 10

3 Answers3

3

If you don't need the data on the server it would probably be easiest to store it on the client side using the HTML5 localStorage JavaScript API or alternatively cookies, if you need to support older browsers.

Matt
  • 74,352
  • 26
  • 153
  • 180
igorw
  • 27,759
  • 5
  • 78
  • 90
  • A great tool for this is [Perist JS](http://pablotron.org/software/persist-js/), which abstracts away the storage mechanism, and lets works with just about any browser. It's really small, too. – OverZealous Aug 14 '11 at 02:03
2

Simply have a column of time_created and either:

  1. Run a cron job that deletes the old records
  2. At every HTTP request, execute a DELETE query that deletes old records (should be sufficiently fast when having index)
Dor
  • 7,344
  • 4
  • 32
  • 45
0

Store it in the session and set the session timeout to 24 hours.

Dark Falcon
  • 43,592
  • 5
  • 83
  • 98
  • http://stackoverflow.com/questions/520237/how-do-i-expire-a-php-session-after-30-minutes – Dor Aug 13 '11 at 22:42