That's because variable interpolation doesn't happen when you use single quotes. Example:
$foo = 'bar';
echo 'The variable is: $foo'; // outputs: The variable is: $foo
echo "The variable is: $foo"; // outputs: The variable is: bar
More information about this can be found on the manual page: [man]string[/man].
In fact, when using variables as array indeces (or function parameters), you don't even need to use a string at all (ex. $_SESSION['cart'][$id] would work).
Also, when posting PHP code, please use the board's [PHP][/PHP] bbcode tags as they make your code much easier to read and analyze.