PHP Classes

Hi, I've edited the construct function to : function __c...

Recommend this page to a friend!

      Class Cart  >  All threads  >  Hi, I've edited the construct...  >  (Un) Subscribe thread alerts  
Subject:Hi, I've edited the construct...
Summary:Package rating comment
Messages:1
Author:Christophe
Date:2009-08-01 00:00:18
 

Christophe rated this package as follows:

Utility: Sufficient
Consistency: Not sure
Examples: Good

  1. Hi, I've edited the construct...   Reply   Report abuse  
Picture of Christophe Christophe - 2009-08-01 00:00:18
Hi,

I've edited the construct function to :
function __construct(){
if( isset($_SESSION['cart']) ){
$this->mArrItem = unserialize($_SESSION['cart']);
$this->mTotal = $_SESSION['mTotal'];
} else {
$this->mArrItem = array(); // inititalize item to array
$this->mTotal = 0; // inititalize total price to 0
}

}

and I've add a destruct function :
function __destruct(){
$_SESSION['cart'] = serialize($this->mArrItem);
$_SESSION['mTotal'] = $this->mTotal;
}

Just to save the product !

Thanks

Bye