Whether to use Session or table

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
Mou
Forum Newbie
Posts: 4
Joined: Fri Aug 24, 2007 6:21 am

Whether to use Session or table

Post by Mou »

I am facing a problem related to a registration page which involves multiple steps. In every step there is a form and there are two buttons one to proceed to next step and another one to go back to previous step. So, if I click on the button proceed to next step then next form appears but if I click on the back button then I go back to the previous step where all the data which I filled should show.

Now my question is how to implement this with PHP? Whether to use Session variables to store the data and show them whenever needed or to use a table where all the data will be stored?

Thanks,
Mou
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

Sessions.
User avatar
Christopher
Site Administrator
Posts: 13596
Joined: Wed Aug 25, 2004 7:54 pm
Location: New York, NY, US

Post by Christopher »

Yes. The session is for data that needs to persist only for the time of the session -- like your multi-page form data. Databases are for that data that needs to persist beyond the time of a session -- user account data for example.
(#10850)
User avatar
Kieran Huggins
DevNet Master
Posts: 3635
Joined: Wed Dec 06, 2006 4:14 pm
Location: Toronto, Canada
Contact:

Post by Kieran Huggins »

You can have both ways by using DB session storage!

On second thought, you should probably ignore this post entirely.
jmut
Forum Regular
Posts: 945
Joined: Tue Jul 05, 2005 3:54 am
Location: Sofia, Bulgaria
Contact:

Post by jmut »

it depends on what you need. Clearly you can achieve this with using sessions or db.
If making orderingprocess or something I would recommend storing all in DB. This way you might collect valuable information to analyze...like on witch step people ditched ordering, if they passed contact and didn't finish, could contact them...etc etc.
Depends what you're doing and if you need to collect all data available.
If still go with sessions...don't forget to validate all data from each step passed! no just the current step.
Post Reply