Q:

Multidimensional session array in PHP

I want to create a multidimensional session array in PHP.
$_SESSION['basket'][$id] = $array

$array refers to an array.
When I run this for a new $id, it is overwriting the previous entry in the $_SESSION['basket'].
Means every time count($SESSION['basket']) is 1.
Actually, i want to achieve following structure.
$_SESSION['basket'] = array($id1 => array(), $id2 => array(), .....)
EDITED:
if(!isset($_SESSION['basket'])) {                           
 $_SESSION['basket'] = array();
 $_SESSION['basket'][$id] = $array;
}
else{
 $_SESSION['basket'][$id] = $array;
}

when i do
$_SESSION['basket'][$id] = implode('/',$array);

it works. but not working for another array as value.
How can i do this?
thanks.

A:

I am providing the answer for my question. It may help some other people who have same issue.
do not store any objects in $_SESSION varibles. I was storing 
$array = array( $key=>object($value),....)

Therefore, I cast object to string
$array = array($key => (string)$value, ...)

and it works.
hope it will help someone.

