This is my first time playing with both ajax and objects, so please go easy on me
I have 3 pages that make up the tester shopping cart.
1) page with 'add' 'remove' buttons and ajax code to call the PHP functions on page 2. this is the actual user page with the HTML output.
2) page with PHP cart function calls, receives $_GET requests from ajax on page 1 and calls functions of the cart object from page 3, returns results to page 1.
3) page with cart object definition.
Here's the problem I believe I'm having. Currently I have 'session_start()' on pgs 1 & 2, and the cart definition (pag 3) on pgs 1 & 2. I only define '$_SESSION[cart]= new Cart' on page 2. However, it seems like each time i hit an ajax function (eg each time pg 2 reloads) it seems like it's rewriting $_SESSION['cart'] over again, thus it's always empty at each new click (even tho it displays results of that click)
However, if i don't define '$_SESSION[cart] = new Cart' on pg 2, i get an error:
Fatal error: main() [function.main]:
The script tried to execute a method
or access a property of an incomplete
object. Please ensure that the class
definition "Cart" of the
object you are trying to operate on
was loaded before unserialize() gets
called or provide a __autoload()
function to load the class definition
in
/home3/foundloc/public_html/booka/carti.php
on line 17
Any suggestions? How can i stop re-creating my cart each time my page 2 (php cart function page) is called by ajax?