Magento: Get User Details

  • Avinash
  • 2
  • Apr 23, 2013
  • Tips & Tricks

In this quick tip we will see how we can get details of logged in customer in Magento.

You can use below code snippet in any model, controller or phtml file.

Get Magento User Details

// Retrieve Session Object $session = Mage::getSingleton('customer/session'); // Check if user is logged in or not. if($session->isLoggedIn()) { $customer = $session->getCustomer(); // Get Customer ID echo $customer->getID(); // Get Customer Name echo $customer->getName(); }
// Retrieve Session Object
$session = Mage::getSingleton('customer/session');

// Check if user is logged in or not.
if($session->isLoggedIn())
{
   $customer = $session->getCustomer();
   
   // Get Customer ID
   echo $customer->getID();

   // Get Customer Name
   echo $customer->getName();
   
}

Let me know if there is any room for improvement in above code snippet.

Related Posts

Written by Avinash

Avinash Zala currently working at a leading web development company as a Sr. PHP Web Developer. He is the founder of the Xpert Developer. He has completed B.E. in Information Technology. Born and brought up in Ahmedabad. He loves to code and coding is all about passion for him. Follow him on twitter at Avinash Zala & Xpert Developer.

View all posts by:

  • Cathlyn

    You saved my lots of hours!!!!! thanks for sharing.!!!!!

  • http://www.biztechconsultancy.com/magento-development.htm Magento Development

    Finally, I got the answer. My searching ended here from your post. Thanks Avinash. You solved my problem.