title: magento 1.8 add product to cart using php
body: <p>Up until Magento 1.7 I was able to use the following code to add a product to cart programatically:  </p>
  
  <pre><code>require_once '../app/Mage.php'; 
  Mage::getSingleton('core/session', array('name' =&gt; 'frontend')); 
  umask(0);  
  Mage::app();  
  $session = Mage::getSingleton('customer/session');  
  $product = Mage::getModel('catalog/product')-&gt;load(99);  // Random product ID
  
  // get cart and add product
  $cart = Mage::getSingleton('checkout/cart'); 
  $cart-&gt;init();
  $cart-&gt;addProduct($product, 1);
  
  // update session
  $session-&gt;setCartWasUpdated(true);
  
  // save the cart
  $cart-&gt;save();  
  </code></pre>
  
  <p>However, this does not work anymore in Magento 1.8. I've been trying/searching all day why this is the case. Sadly I haven't found any clue regarding this issue.  </p>
  
  <p>It may have to do with the changes in 1.8 which also causes the requirement for a form-key when using the URL method; this is a wild guess though.</p>
  
  <p>Anyone any idea or a working example on how to do this when working with Magento 1.8?</p>