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.
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
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.
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