如何获得Magento客户ID

Ugh how do I get the customer ID!!? These are all things I've tried! Can you see what I'm doing wrong?

//include_once "app/Mage.php";
require_once '/home/ab71714/public_html/app/Mage.php';

//Mage::app("default");

Mage::app()->setCurrentStore(Mage_Core_Model_App::ADMIN_STORE_ID);

if($customer = Mage::getSingleton('customer/session')->isLoggedIn()) {
    $customerData = Mage::getModel('customer/customer')->load($customer->getId())->getData();
    print_r($customerData);
    echo $customerData->getId();
}

//$customerData = Mage::getModel('customer/customer');
//$customerID = $customerData -> getId(); 

//$userinfo = $customerData->_origData; // fetch users info
$customerID=$customer -> getId(); 
//$customerID = $customerData->getEntityId();
//$customerID = $customerData[entity_id];

Try

 if(Mage::getSingleton('customer/session')->isLoggedIn()) {
     $customerData = Mage::getSingleton('customer/session')->getCustomer();
      echo $customerData->getId();
 }

See Current user in Magento?

The function isLoggedIn will only return a boolean as to if a customer is logged in and no other information.

The customer session does have to following functions:

  1. getCustomerId: which will return the customer id

  2. getCustomer: which will return the customer object.

The fastest way is

Mage::getSingleton('customer/session')->getId()