you should:
convert you array into a string
store the string in db
pull string from db
convert string to array
Most used is [man]implode[/man] and to convert back [man]explode[/man]
It will work on simple arrays, but not with multidimensional.
in your case $myarray would be: $_SESSION["cart"]
To get the keys + values, makes it more complicated
Maybe make 2 strings: 1 with the keys and 1 with values
But as you use: $_SESSION["cart"][$id] = $id;
it makes it rather easy to fix ( see my foreach loop )
<?php
session_start(); // in the beginning of script
// some substring youre sure doesnt exist in array values!
$delimiter = '_#_';
$string = implode( $delimiter, $myarray );
// Pull back the array ------------------------
session_start(); // if wasnt started before in script
$delimiter = '_#_';
$arr = explode( $delimiter, $string );
foreach($arr AS $id ){
$myarray[$id] = $id;
}
$_SESSION["cart"] = $myarray;
?>