If you are writing a custom module, and you want it to be accessed only by admins, then you possibly need the following code in your controller.
//get the admin session Mage::getSingleton('core/session', array('name'=>'adminhtml')); //verify if the user is logged in to the backend if(Mage::getSingleton('admin/session')->isLoggedIn()){ echo "Admin Logged in"; } else { echo "You need to be logged in as an admin."; }







Hi, thanks for this snipped.
I tried to put the code in my header.phtml but it return always “You need to be logged in as an admin.” even if I’m logged in the admin panel.
What’s wrong? I’m running on Magento 1.5.
Thank you
Hello, thanks for this code.
I tried to implement it in frontend, but it return always the message “You need to be logged in as an admin.” Any help?