title: Retrieving the order_id of a current checkout session within an observer in Magento
body: <p>I am trying to retrieve the <code>order_id</code> of an order that has just been created during checkout process (after the place order button was clicked).</p>
  
  <p>I have an observer listening to the <code>sales_order_place_after</code> event. I am trying to retrieve the <code>order_id</code> using this code :</p>
  
  <pre><code>$orderId = Mage::getSingleton('checkout/session')-&gt;getLastRealOrderId();
  </code></pre>
  
  <p>which returns the <code>order_id</code> of the previous order and not the current order that was just created during the checkout. If I use something like this : </p>
  
  <pre><code>$order = Mage::getModel('sales/order');
  $order-&gt;load(Mage::getSingleton('sales/order')-&gt;getLastOrderId());
  $lastOrderId = $order-&gt;getIncrementId();
  </code></pre>
  
  <p>I do not get the <code>order_id</code>.</p>
  
  <p>The reason I am trying to do this is to set all the order status to hold or pending when they are created initially and when the user made a successful transaction, I will be changing the status to processing.</p>
  
  <p>How do I retrieve the current <code>order_id</code> for the checkout session in progress within a observer?</p>