$_SESSION not fully cleared?
Posted: Wed Nov 01, 2006 11:34 am
hi there, had a very big problem since i started to use $_SESSION. Its has been a very great tool for my shopping cart. But when i cleared all the items in my shopping cart, it doesn't seems to clear everything thing in the session. For example, It will appears as the same setting as its cleared if i add on the same item! *Big headache* anyone? help help!!
The below is the part where i unset or set the Session.
this part is whereby i verify if the session is there or not..
The above works fine for one session item. But when i did the same to another like 'member', it just loops my new items like previous.
The below is the part where i unset or set the Session.
Code: Select all
foreach ($_POST['txtQty'] as $key => $value) {
if((($value == 0) AND (is_numeric ($value))) OR $chkRemove[$key]=="on"){
unset($_SESSION['cart'][$key]);
unset($_SESSION['member'][$key]);
unset($_SESSION['repack'][$key]);
}elseif(is_numeric ($value) AND ($value > 0)){
$_SESSION['cart'][$key] = $value;
if($chkMember[$key]=="on"){
$_SESSION['member'][$key]="CHECKED";
}
if($rdRP[$key]=="1"){
$_SESSION['repack'][$key]="1";
}elseif($rdRP[$key]=="2"){
$_SESSION['repack'][$key]="2";
}elseif($rdRP[$key]=="3"){
$_SESSION['repack'][$key]="3";
}
}elseif(is_numeric($value)==false){
$intNum="1";
if($chkMember[$key]=="on"){
$_SESSION['member'][$key]="CHECKED";
}
if($rdRP[$key]=="1"){
$_SESSION['repack'][$key]="1";
}elseif($rdRP[$key]=="2"){
$_SESSION['repack'][$key]="2";
}elseif($rdRP[$key]=="3"){
$_SESSION['repack'][$key]="3";
}
}
}Code: Select all
if(isset($_SESSION['cart'])){
$countItems=0;
foreach ($_SESSION['cart'] as $id => $val) {
$countItems++;
}
if($countItems>0){
blablabla..
}
}