Welcome Guest, Not a member yet? Register   Sign In
Would you save data in a session or database for a large multi-step form?
#1

[eluser]jleequeen[/eluser]
Hey Guys,

I've got a controller that basically is a breakdown of a large form that a user needs to submit. For instance, I have methods called form/step_1, form/step_2, etc. I've broken it down this way because it's easier to do validation on small parts. Also, some of the screens involve being able to add multiple rows of data instead of just a simple form.

What I'm wondering, is if it's better to save to the database after each screen, or save the information to the session, then save to the database at the end. I can see pros and cons either way. For instance, the session could be lost or time out, and they'd have to start all over. As far saving to the database as they go, they may not finish all the way to the end, then records are left in the database that are not complete.

Anyone have any suggestions or best practice?
#2

[eluser]elciel[/eluser]
Well, CI can keeps session data in a DB (optional , configuration change required).
http://ellislab.com/codeigniter/user-gui...sions.html

Also, from the same page in the guide, "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."

I hope that will help you make your decision.
#3

[eluser]überfuzz[/eluser]
I'd go for session, if the info is under 4KB. I can't imagen a user that have to spend $config['sess_expiration'] = 0; on each step. ;-) If so, you might consider easing each step down a bit.




Theme © iAndrew 2016 - Forum software by © MyBB