What are the do's and don'ts about Cache VS Session VS Cookies?
For example: Im using Session variables a lot and have sometimes problem in a booking-application when users starts to order products and then goes to lunch and come back some hours later and continue the booking. I store the booking in the session until the user confirm or abort the booking so I dont need to talk to the database and handle halfway bookings in the database when users just click the X in the browser and never comes back.
Should I instead use cashe or cookies or any combination of all above for this?
(I have also had problems as when there are some error in the app the sessison-object resets itself and I got a lots of more problems because of that)
Im mostly doing desktop-programming and feel I lack a lots of knowledge here so anyone who can expand on where to use Cache, Session, cookies (or db)
Edit: From the answers it seems that a combination of DB and cookies is what I want.
- I have to store the booking in the database connected to a session-id
- store the session-id in a cookie (encrypted).
- Every page load checking the cookie and fetch the booking from the database
- I have a clean-up procedure that runs once a week that clears unfinnished bookings.
I cant store the booking as a cookie because then the user can change prices and other sensitive data and I had to validate everything (cant trust the data).
Have I got it right?
And thanks for great explanations to all of you!