I have a "page" class that on it's construct includes a "shoppingCart" class, starts a session, creates a shoppingCart object, and then sets $_SESSION['shoppingCart'] to the shoppingCart object.
I still get an incomplete class when I print_r the session...
I thought this only happens when you start the session before including the class?
The code in my "page" class looks like this:
include ('include/shopping_cart.php');
if (session_id() == '')
{
session_start();
}
if (!isset($_SESSION['shoppingCart']))
{
$_SESSION['shoppingCart'] = new shoppingCart;
}
I obviously don't understand this... Please help!
To store an object in a session two things must happen:
1) The class must be defined before the session is started. 2) The class must implement serializable.