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.