robert_gsfame Posted April 14, 2010 Share Posted April 14, 2010 I try to create add to carts, but i face this problem..below i attach the code assume checkvalue= 6;8...then i explode the value using ";" as the separator and then i loop the value and check whether there is an old SESSION already...if not then i set the new one or else adding (+1) the new session array. besides i don't want the same record to be stored in $_SESSION array so i check it first 2 problems occured: * When $_SESSION['basket'][0] not yet exist, i fail to create the new one * i still can store the same record again and again although i have the old one $checkvalue=$_GET['checkvalue']; $explode=explode(";",$checkvalue); $count=count($explode); $countbasket=count($_SESSION['basket']); for($i=0;$i<$count;$i++){ if(!isset($_SESSION['basket'][0])){ $x=0;}else{ $total=count($_SESSION['basket']); $x=$total+1;} $find=0; for($a=0;$a<$countbasket;$a++){ if(base64_encode(urlencode($explode[$i]))==$_SESSION['basket'][$a]){ $find++;}} if($find>0){ $_SESSION['basket'][$x]=base64_encode(urlencode($explode[$i]));}} thanks for any helps Link to comment https://forums.phpfreaks.com/topic/198470-_session-problem/ Share on other sites More sharing options...
robert_gsfame Posted April 14, 2010 Author Share Posted April 14, 2010 okay i think i've found what cause the problem if($find>0){ $_SESSION['basket'][$x]=base64_encode(urlencode($explode[$i]));}} it should be equal to zero not greater Link to comment https://forums.phpfreaks.com/topic/198470-_session-problem/#findComment-1041457 Share on other sites More sharing options...
oni-kun Posted April 14, 2010 Share Posted April 14, 2010 Formatting and tags would help for reference.. Why are you applying base64_encode over urlencode? Link to comment https://forums.phpfreaks.com/topic/198470-_session-problem/#findComment-1041458 Share on other sites More sharing options...
robert_gsfame Posted April 14, 2010 Author Share Posted April 14, 2010 i try to avoid whitespace once being decode Link to comment https://forums.phpfreaks.com/topic/198470-_session-problem/#findComment-1041464 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.