Welcome Guest, Not a member yet? Register   Sign In
multidimensional session
#1

[eluser]arlabbafi[/eluser]
hi
To create a multidimensional session What should I do ?
#2

[eluser]ciGR[/eluser]
Code:
$array = array(
         'username'=>'name',
         'email'=>'[email protected]'
);
$this->session->set_userdata('user',$array);

//and after you get

$user = $this->session->userdata('user');
print_r($user);
#3

[eluser]arlabbafi[/eluser]
thank you
now i create a multidimensional session like this
Code:
$array = array(
    $row++ => array(
            'basket_id'=>'',
            'order_id'=>'',
            'cus_id'=>$cusid,
            'product_id'=>$pro_id,
            'bas_quantity'=>1
    )
);
$this->session->set_userdata('cart',$array);
now i want to Each time that create "cart" session it add to row and when i want to remove session "cart" with one Command like unset_userdata('cart') remove all Subset session in cart
What should I do ?????
#4

[eluser]arlabbafi[/eluser]
Is a solution?
Please help me.
#5

[eluser]ciGR[/eluser]
I misunderstand what exactly you want.
the simple occasion is

Code:
$row => array(
            'basket_id'=>'1',
            'order_id'=>'1',
            'cus_id'=>$cusid,
            'product_id'=>$pro_id,
            'bas_quantity'=>1
    )

$cart = array($row);

$this->session->set_userdata('cart',$cart);
to add a new row just get the array from the session and add a new row
Code:
//get the cart
$cart = $this->session->userdata('cart');

//create the new row
$new_row => array(
            'basket_id'=>'2',
            'order_id'=>'2',
            'cus_id'=>$cusid,
            'product_id'=>$pro_id,
            'bas_quantity'=>1
    )

//add new row to cart
$cart[] = $new_row;

//or you can set it with a key, for find easier a session row by a id
// $cart[$pro_id] = $new_row;

//save cart to session
$this->session->st_userdata('cart',$cart);
also you can see the CI cart library if it can help you
#6

[eluser]arlabbafi[/eluser]
thank you solved




Theme © iAndrew 2016 - Forum software by © MyBB