Recently we got project about magento what require to lock all of guest access. The site only accept user logged and all of pages in magento is private for users only. That mean we have to the member only magento site.

get user information

In addition, we can build a welcome page or any page base on logged user from this article. Now will show you how to check and get user information.

From everywhere in magento code you can check login by this code line

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

You may want to know full information about the current customer/user. You may check this debug code

$customer_data=Mage::getSingleton('customer/session')->getCustomer();
echo "<pre>" print_r($customer_data);

Or you can get customer information via help instead of Singleton object

Mage::helper('customer')->getCustomer()->getData();

It should return the same result data. Good luck for your coding

2 thoughts on “Get current logged user/customer in magento

  1. I think we only need to use this api Mage::getSingleton(‘customer/session’)->isLoggedIn() then the problem will be solve. Because we just need to capture the login status to redirect to the member area.

    1. Yes, it ‘s one of a good way to get current session of user. But belong to many factors, I don’t know why but sometimes in block we can’t use it. Maybe conflict with somethings else

Leave a Reply