I found this tutorial:
http://www.devarticles.com/content.php?articleId=132&page=1
I recently needed to implement a simple shopping cart so I wrote a basic Cart class and stuck an instance of it in the session. This is a different approach than the above tutorial's -- he keeps the all the cart data in MySQL.
At the top of each page that participates, I require() the file that contains my Cart class declaration. Then start the session with session_start().
Next, I want to know if they have a cart yet, if not, create it and stick it in the session; otherwise, take a reference to it. (If anyone sees anything wrong with this I'd sure appreciate hearing about it. )
if (!isset($SESSION["cart"])) {
$cart = new Cart();
$SESSION["cart"] = $cart;
} else {
$cart = &$_SESSION["cart"];
}
I found it convenient to put a object ref in $cart so I could save some typing by saying $cart->doSomething() instead of the more awkward $_SESSION["cart"]->doSomething().
I simply kept my items (which are fetched from a MySQL table) in an array, which is one of the cart's fields, and called my add() and remove() methods as needed. In my particular case I didn't need to worry about quantity of individual items, as this happened to be a one-to-a-customer scenario.
I'm rather new to PHP sessions and OOP myself so caveat emptor. But I found it pretty easy and fun to do the above.