Do you have eCart? You will need it to add this server behavior in. With eCart installed open up the confirm page and apply the eCart > data manipulation > store order summary and store order details in db.
This will ensure that the cart's contents and any other info relating to the order will be stored in your db. Please post back with any specific questions that you have about any part of this.