title: Magento cart / session data outside magento
body: <p>This might get a little confusing as I have tried everything to make this work. All I want is a link in my brand site (domain.com) which shows the qty in my magento 1.5.1 cart (domain.com/shop) I quite easily pulled in product data and navigation blocks but no matter what I do, cart qty is always 0 from outside magento.
  The main way I tried was just in my brand site to go: </p>
  
  <pre><code>    require_once $_SERVER['DOCUMENT_ROOT'].'/shop/app/Mage.php';
      umask(0);
      Mage::app();        
      Mage::getSingleton('core/session', array('name'=&gt;'frontend'));
      // trying everything 
      Mage::getSingleton('checkout/cart')-&gt;getItemsCount(); // returns 0
      Mage::helper('checkout/cart')-&gt;getItemsCount(); // returns 0
      Mage::getSingleton('customer/session')-&gt;isLoggedIn(); // returns blank
      Mage::helper('checkout/cart')-&gt;getCart()-&gt;getItemsCount(); // returns 0
      Mage::helper('checkout/cart')-&gt;getCart()-&gt;getQuote()-&gt;getItemsCount(); // returns blank
  </code></pre>
  
  <p>Then, when none of those worked, I created a template in Magento just to give me the cart qty as a block which returns the block fine but still zero in the cart!</p>
  
  <pre><code>    $block = $this-&gt;layout-&gt;createBlock('core/template');
      $block-&gt;setTemplate('page/html/cartForBrand.phtml');
      return $block-&gt;renderView();
  </code></pre>
  
  <p>and the block in magento is simply</p>
  
  <pre><code>    Mage::getSingleton('core/session', array('name'=&gt;'frontend'));
      $cart = Mage::getModel('checkout/cart')-&gt;getQuote()-&gt;getData()['items_qty'];
  </code></pre>
  
  <p>I've seen a lot of people having similar issues: <a href="https://stackoverflow.com/questions/1098871/how-to-access-magento-users-session-from-outside-magento">/ session_cookie_management</a>, <a href="https://stackoverflow.com/questions/9982210/how-to-access-magento-customers-session-from-outside-magento">.domain.com cookie_domain</a>(even though that's subdomain specific), I've read and tried everything I could find for 2 days. Constantly deleting session and cache directories and clearing cache and cookies with magento caching disabled. </p>
  
  <p>This is the first question I've posted on this site after using it for years, I've been stuck on this for 3 days! Pulling my hair out!</p>