Session variables are definitely a more reliable way to store your cart data since you can't rely on the user having cookies enabled (even though most do).
When submitting form data you will need to pass the session id as a hidden variable similar to the following:
<form method="post" action="...">
<input type="hidden" name="PHPSESSID" value="<?echo $PHPSESSID; ?>">
...
</form>
I believe using method="POST" is what you would want to use when sending data from a form to a CGI program. Get will display the form variables and values in the URL.
You don't need to store the session data in your database however you can do so if you wish. I think by default session data is stored as a file in the /tmp/ directory on your unix system. This can be changed in the php.ini file.
Here's how a session gets created:
<?php
session_start(); // Creates a unique session id for the current user.
session_register("variable_name");
$variable_name = 5;
?>
NOTE: now whenever you call session_start() in any other scripts, $variable_name with the value 5 will be available to that script.
<?php
session_start();
session_destroy();
?>
The above script destroys the active session and any variables registered in that session. Only do that when you are sure the user will no longer need that data.
I have left a lot of details out so you should consult the PHP manual and check out a tutorial on PHP session management.
Hope this helped.
--Craig.