title: magento - access cart in external PHP file
body: <p>Trying to access the magento cart from an external php file, I have loaded Mage and am able to access products &amp; categories but for some reason I'm unable to access the cart information.</p>
  
  <p>Shop is located in www.domain.com/shop/
  PHP File is located in www.domain.com/file.php
  Magento cookie setting is set to '/'</p>
  
  <p>I have looked at and tried many example of how to get the information and none of them have worked, the code I have at the moment is:</p>
  
  <pre><code>&lt;?php
  require_once '/home/admin/public_html/shop/appMage.php';                                                        
  Mage::app();
  Mage::getSingleton('checkout/cart', array('name' =&gt; 'frontend'));               
  $cartItemsCount = Mage::getSingleton('checkout/cart')-&gt;getItemsCount();
  $cartTotal = Mage::helper('checkout')-&gt;formatPrice(Mage::getSingleton('checkout/cart')-&gt;getQuote()-&gt;getGrandTotal()); 
  
  echo 'You have '. $cartItemsCount . ' item(s) in your cart. &lt;a class="cartgo" href="'.Mage::helper('checkout/cart')-&gt;getCartUrl().'"&gt;Checkout&lt;/a&gt;';
  if($cartTotal &gt; 0){ echo '&lt;span&gt;[&amp;pound;'.$cartTotal.']&lt;/span&gt;'; }
  echo '&lt;/a&gt;';
  ?&gt;
  </code></pre>
  
  <p>It works perfectly fine within the magento site but not from this external file for some reason. It returns a 0 even though there is a product in the cart.</p>
  
  <p>Any pointers?</p>