I’m working on a web application which will take user input, display it and then populate a database only is user clicks a ‘Save Button’.
The concept similar to “jsfiddle”, where it will allow you to create but not save until user decided, then it will as well create a custom url.
The question is:
What will be a good approach to hold user entries until saved?
- Session Array (which get’s pushes to db upon ‘save button’)
- Temporary Mysql Table Records
- Cookies / Session Combination
Please advice if the question needs more clarification. Question is more towards temporary records. PHP language.
First of, you can’t store arbitrary amounts of data in a cookie – have a google for the RFCs (IIRC, the limit is set on the size of all cookies for a particular host).
Nor can you use mysql temporary tables – the mysql session session only runs as long as the PHP script – at the end of the mysql session (not the PHP session which is a mechanism for making data persist between invocations of the interpreter) , the temporary tables are lost.
The most efficient solution will depend on how often users abandon data entry and the range of sizes in the working set, but the simplest solution would be to store the data in the table where it would eventually be written to – but flag it as a working copy with a link to the user id or session id.