Jump to content

$_SESSION problem


robert_gsfame

Recommended Posts

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

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.