Page 1 of 1

Autosave - how to

Posted: Wed Oct 26, 2005 12:40 pm
by btm
Hi all,
Basically, I have a password-protected site with about 1,000 users. There is a lot of sensetive, individualized information that users have access to and can edit/add to. There's an auto-timeout set for 15 minutes, but we're finding that more and more users are spending a long time entering text, getting logged out, and losing their work. I'm trying to develop or find a PHP script that we can use to autosave the data and pull it back up if they are logged out and then log back in. I'm pretty new to PHP and honestly don't really know where to start :?: . Does anyone know of any relevant scripts out ther or have any suggestions?
Thanks!

Posted: Wed Oct 26, 2005 1:18 pm
by Chris Corbyn
If this is form data, and you want it saved before submitting to the server either use cookies/javascript to save the info (only small amounts of text though!!). Or, slightly nicer, use ajax to send data at set intervals to the server transparently. The latter method can be used in conjunction with mysql to save and retreive the data.

Check out XAJAX ( http://xajax.sourceforge.net/ )... You'll need some basic JS knowledge for it though.

Posted: Wed Oct 26, 2005 11:28 pm
by John Cartwright
Basically if you are using the AJAX method, which I would also recommend (but it is slightly advanced for most users) then you are going to, as mentioned by d11 that you will have an update of set intervals, lets say every 1-5 minutes (depending on how frequently you want the information to be saved) to a temporary storage table in mysql. I would most likely keep the interval at every couple of minutes, because you may have some issues with your server load, depending on how many active users you have.

Secondly, you would require some form of garbage cleanup for these temporary input tables. I would have each time they input a new page (whatever the user is inputting) assign that entry id. How I see it your going to need an identifier to know when to delete the temporary tables -- When that particular id appears in the "final draft (where the user has submitted the input for good)" your garbage cleanup routines should prune your temporary input tables. Also, a cronjob may be best in this situation for the cleanup set to once atleast once a day, instead of having some lazy checking on every page load.

I think that should give you a couple ideas..

Posted: Thu Oct 27, 2005 12:37 pm
by btm
Thanks a lot guys!
We're going to actually do a short-term fix and a long-term permanent fix. First we're going to simply call a function to insert the data every 5 minutes and reload the page and I'm going to get a good grasp of ajax and we'll go with your suggestions.

Thanks again!