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
The above solutions doesn't work!
Here is a solution that works ( its not that clean ! but this will work anywhere in your 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);// this will be true if admin logged in and false if not