Welcome Guest, Not a member yet? Register   Sign In
Session update
#1

[eluser]spagi[/eluser]
Hi i have a problem with create user'session data ....I want to creat eschop'basket ....If i am "buy" only one item, It's everithing OK. But if i "buy" more ....I have in basket only the last item .
Can anyone explain what is wrong?
Code:
function save(){
    
     $array=array('name'=>$this->uri->segment(4),
                    'table'=>$this->uri->segment(3),
                    'varianta'=>$_POST['varianta'],
                    'num'=>$_POST['num']
                   );
    
      $this->session->set_userdata($array);
    
    
     $this->load->helper('url');
redirect('/eshop/');
#2

[eluser]Pascal Kriete[/eluser]
You're overriding the keys everytime. I think what you're shooting for is a multidimensional array:

Code:
$current_basket = $this->session->userdata('basket');

$new_item = array(
    'name' => $this->uri->segment(4),
    'table' => $this->uri->segment(3),
    'varianta' => $_POST['varianta'],
    'num' => $_POST['num']
);

$current_basket[] = $new_item;

$this->session->set_userdata('basket', $current_basket);
#3

[eluser]spagi[/eluser]
Thank you very much




Theme © iAndrew 2016 - Forum software by © MyBB