Magento: Detect if admin is logged in in frontend pages

后端 未结 12 562
轻奢々
轻奢々 2021-02-04 00:09

I have created a magento extension. I want to implement access to the extension. The extension creates a page in frontend and i want only admin to access that page. So basically

12条回答
  •  有刺的猬
    2021-02-04 01:12

    require_once $dir.'app/Mage.php';
    umask(0);
    
    $apps = Mage::app('default');
    Mage ::getSingleton('core/session', array('name'=>'adminhtml'));
    $adminSession = Mage::getSingleton('admin/session');
    $adminSession->start();
    if ($adminSession->isLoggedIn()) {
       //echo "logged in";
    } 
     else { 
          //echo "Not logged in";
          exit();
     }?> 
    

提交回复
热议问题