I am working on a web application page which consists of a form that is three pages long (I’m constrained to keep it that way for the users, even though it is not the most efficient way of doing it).
My question is: What is the best practice for keeping track of the information from one page of the form to the next? Generally, we store everything in session variables until the last form where we make a stored procedure call or in-line SQL to update the database with the results of the form. The other option would be to use in-line SQL page-by-page to store the data before going from one page to the next.
TL;DR – session variable storage of data and SQL after 3 pages, or in-line SQL at each page?
Thanks!
I would suggest to save the entered data on each page in a database. The data could be saved into one (temp) table by session ID. If user clicks the “Finish” or “Submit” button then the data is “activated” by coping the data from temp. table into normalised tables.
However, this solution requires you to deal with dead session which never end up copying into it’s final place. Therefore, a clean up task is needed to set up. This could be a MS SQL Job or any SQL query to the database checks the last clean-up time and performs it if the before set time interval is reached.
Storing everything in a session is not a good way. Especially if they keep a larger data set or if there are many concurrent users. The reason is that the HTTP sessions are stored in text files in the server and consume I/O. This makes it slow compared to a RDB.