php - Magento: Detect if admin is logged in in frontend pages -


i have created magento extension. want implement access extension. extension creates page in frontend , want admin access page. need detect if admin logged in in frontend pages.

i have tried several solution noting seem work .

if(mage::getsingleton('admin/session', array('name' => 'adminhtml'))->isloggedin()) echo 'logged in'; else echo 'not logged in'; 

check on frontend if admin logged in

mage::getsingleton('core/session', array('name'=>'adminhtml')); $adminsession = mage::getsingleton('admin/session'); $adminsession->start(); if ($adminsession->isloggedin()) {    echo 'logged in'; } 

the above solutions doesn't work!

here solution works ( not clean ! work anywhere in application in phtml view or model or controller or helper ! )

$sesid = isset($_cookie['adminhtml']) ? $_cookie['adminhtml'] : false ; $session = false; if($sesid){     $session = mage::getsingleton('core/resource_session')->read($sesid); } $loggedin = false; if($session) {     if(stristr($session,'mage_admin_model_user'))     {         $loggedin = true;     } } var_dump($loggedin);// true if admin logged in , false if not 

Comments

Popular posts from this blog

monitor web browser programmatically in Android? -

Shrink a YouTube video to responsive width -

wpf - PdfWriter.GetInstance throws System.NullReferenceException -