Welcome Guest, Not a member yet? Register   Sign In
Multi Page Forms
#1

[eluser]Unknown[/eluser]
In regards to sessions and multi page forms - what is the best practice to handle data persistence across multiple pages (assuming the user is not required to login or have any type of account)?

My thought was to enable session storage in the database and then link that session id as a primary key in my main data table. I would then update the main table with each subsequent form post.

Or would it be better (performance wise) to store everything in the cookie (it's encrypted anyway) and then dump into the db once the process is complete? I realize there is a 4K limit to the cookie, and the amount of data in the multiple forms will fit within that limit.

My main concern is that I do not want the db cluttered with a bunch of half completed rows. I guess I could always throw an "is_complete" column at the end of the table and set it to true at the last form post.

What do you all think?
#2

[eluser]Colin Williams[/eluser]
That IS what sessions are for, after all. Persistent data. You're definitely on the right path.

Quote:My main concern is that I do not want the db cluttered with a bunch of half completed rows.

From the User Guide:

Quote:Note: The Session class has built-in garbage collection which clears out expired sessions so you do not need to write your own routine to do it.
#3

[eluser]erik.brannstrom[/eluser]
I don't know if I followed you right, but I would probably add the data to the database after each form and then, like you said, keep some sort of record of the progress. Maybe a 'process_activity' field that keeps the date and time of the last addition, and NULL if finished. Every now and then you can remove all entries where that field is not NULL and more than two hours old.
#4

[eluser]flojon[/eluser]
I suggest that you store each form to the session and only store it to the database when all forms are complete. If you want to have sessions in the database I suggest you take a look at OBSession which will handle the garbage collection for you.
#5

[eluser]Sarfaraz Momin[/eluser]
The best way I did it was using hidden fields on every page except for the first page. What I did was I used hidden fields on page 2 onwards to carry data for all the fields prior to that page. Its was pretty good and no issues for it being used.

Have a good day !!!
#6

[eluser]Colin Williams[/eluser]
Quote:The best way I did it was using hidden fields on every page except for the first page

That fails pretty quickly if you intend to allow the user to become interrupted somewhere throughout the process, which many inevitably will. I'm not sure why it would be so confusing to just put completed entries in the session, and then by checking which sections have/haven't been completed, you'll know what set of form elements to display.

Whether or not you use a library that stores session data in a database table is a totally separate deal. The core session garbage collection still works on something like DB2_Session. I would recommend one always uses a library like DB2_Session




Theme © iAndrew 2016 - Forum software by © MyBB