Getmagento does not store product id from your quote objectcategory name where user added it.
$cart = Mage::getSingleton('checkout/session')->getQuote();
or You need to do customise it.
$cart = Mage::getModel('checkout/cart')->getQuote();
And load productsFor it you need to create custom column in order_item and quote_item table and with observer (itemscheckout_cart_product_add_before) need to save current category name.
foreach ($cart->getAllVisibleItems() as $item)
{
$productId = $item->getProduct()->getEntityId();
$product = Mage::getModel('catalog/product')->load($productId);
$cats = $product->getCategoryIds();
foreach($cats as $catid)
{
$_category = Mage::getModel('catalog/category')->load($categoryId);
echo $categoryName = $_category->getName();
}
}
Get Categories from product id.Current category
$product$category = Mage::getModel('catalog/product')->load($productId);
$cats = $product->getCategoryIdsregistry('current_category');
foreach($cats as $cat)
{
$_category =$categoryid Mage::getModel('catalog/category')=$category->load>getId($cat);
echo $categoryName = $_category->getName();
}