Reputation: 1418
I've tried various methods to get the customerID but an empty value is stored in the variable. Please advise :)
Below remnants of things I've tried. The file is located in the root.
require_once '/home/ab71714/public_html/app/Mage.php';
//Mage::app("default");
Mage::app()->setCurrentStore(Mage_Core_Model_App::ADMIN_STORE_ID);
/* if(Mage::getSingleton('customer/session')->isLoggedIn()) {
$customerData = Mage::getSingleton('customer/session')->getCustomer();
echo $customerData->getId();
} */
if(Mage::getSingleton('customer/session')->isLoggedIn()) {
$customerId = Mage::getModel('customer/session')->getCustomer()->getId();
} else {
echo 'Not logged In';
}
Upvotes: 0
Views: 5613
Reputation: 21
if(Mage::getSingleton('customer/session')->isLoggedIn()) {
$customerData = Mage::getSingleton('customer/session')->getCustomer();
echo $customerData->getId();
}
Upvotes: 2
Reputation: 5685
require "/home/ab71714/public_html/app/Mage.php";
umask(0);
Mage::app();
$session = Mage::getSingleton('customer/session');
if($session->isLoggedIn()) {
print_r($session);
$customerId = $session->getCustomer()->getId();
} else {
echo 'Not logged In';
}
For more information:
http://ka.lpe.sh/2011/06/19/magento-get-customer-details-customer-id-name-email/
Upvotes: 2