Here is how the cart is cleared for the current session user:

    $cart = Mage::getSingleton('checkout/cart'); 
    $quoteItems = Mage::getSingleton('checkout/session')
                      ->getQuote()
                      ->getItemsCollection();
     
    foreach( $quoteItems as $item ){
        $cart->removeItem( $item->getId() );    
    }
    $cart->save();

My question is how can i clear cart by user id, not by session?