Magento : Check If Admin Is Logged In Or Not In Frontend

It is a not a clean code.
To check the magento admin user is logged in or not in admin panel, you can use following custom php script to check in/from frontend.
You can also use this code in controller, helper, model or phtml files for the same checking.
define('MAGENTO_ROOT', getcwd());
require_once MAGENTO_ROOT . '/app/Mage.php';
$sessionId = isset($_COOKIE['adminhtml']) ? $_COOKIE['adminhtml'] : false;
$session = false;
if ($sessionId) {
    $session = Mage::getSingleton('core/resource_session')->read($sessionId);
$loggedInFlag = false;
if ($session) {
    if (stristr($session, 'Mage_Admin_Model_User')) {
        $loggedInFlag = true;

Leave a Reply