How do I make certain frontend pages accessible only by admin? I have tried using Mage::getSingleton('core/session') and Mage::getSingleton('admin/session') to no good end. Any suggestions?

Oh, and by pages I mean frontend controller actions in case that wasn't clear.

2 Answers 2


I would suggest observing controller action predispatch events like this:


It will fire on every controller action call.

Then inside of myPredispatchObserver method you can check if current controller is one from those you want to restrict to admin user. You can get current controller name like this:


Finally you can check if current session belongs to admin. You can try any of the following methods:

Mage::getSingleton('admin/session', array('name'=>'adminhtml'))->isLoggedIn());

// or


// or


Finally if user is not an admin redirect him to the referring page.


I'm sorry but magento still splits admin and customer session. Therefore you don't know in the frontend whether some user is admin and logged in.

Magento sets two cookies, one namened frontend and one named adminhtml. If magento initializes PHP's cookie support with session_name frontend, you get the customer's data, if magento uses adminhtml, you load the admin data.

What you can do is write an admin controller and get the data via AJAX, but then they still are submitted from admin.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.