views:

39

answers:

2
function  mycart($mydate=null,$day=null)
 {
  $mycart= $this->session->userdata('mycart');
  $totalprice=$this->session->userdata('totalprice');

    if($this->limitation($mydate) && (!(isset($mycart[$mydate]))) )
    {          
     $mycart[$mydate] = array(
     'meal' =>$this->session->userdata('meal'),
     'day' =>$day,
     'date' =>$mydate,
     'disable'=>FALSE,
     'flag'=>null);
     $this->session->set_userdata('mycart',$mycart);  

     $this->session->set_userdata('totalprice',$totalprice);
    }// end  of if        

 }//  end  of  function

I am saving an array called $mycart in session but only 10 carts, i.e, only 10 records are getting saved after which 11th one is not getting saved in session. The session only save 10 array element can any one tell me why??

A: 

Perhaps your issue is with your array itself. If you have two carts with the same $mydate value, the latter will override the first value. You need to use a multidimensional array in this case, i.e.:

$mycart[$mydate][] = array(
     'meal' =>$this->session->userdata('meal'),
     'day' =>$day,
     'date' =>$mydate,
     'disable'=>FALSE,
     'flag'=>null);

Otherwise you may perhaps be skipping with your first check on isset($mycart[$mydate]), which would essentially skip over an entire cart.

cballou
No same carts are not getting stored I checked with that possibility .The (!(isset($mycart[$mydate]))) condition doesnt allow to add other cart with same key name.I before 11th records everything is working fine.But after 10 carts are saved in session its just not saving the 11th one.Is there limitation on the number of items we save in session???do i need to do some kind of settings.
nupura
+1  A: 

The code you've posted is irrelevant to the problem you describe.

Try creating code from scratch to replicate the issue.

C.

symcbean