What are common pitfalls when using PHP sessions for storing data like a shopping cart?

Common pitfalls when using PHP sessions for storing data like a shopping cart include not properly serializing complex data structures before storing them in the session, not checking if the session is already started before trying to start it again, and not properly handling session expiration and cleanup.

<?php
// Start the session if it hasn't been started yet
if (session_status() == PHP_SESSION_NONE) {
    session_start();
}

// Serialize the shopping cart data before storing it in the session
$cart = array(
    'item_id' => 123,
    'quantity' => 2,
    'price' => 19.99
);
$_SESSION['cart'] = serialize($cart);

// To retrieve the data from the session, unserialize it
$cart_data = unserialize($_SESSION['cart']);