Skip to content

Instantly share code, notes, and snippets.

@gelanivishal
Created June 13, 2017 16:33
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save gelanivishal/89cffe858ed4fdac401f402075836437 to your computer and use it in GitHub Desktop.
Save gelanivishal/89cffe858ed4fdac401f402075836437 to your computer and use it in GitHub Desktop.
M1 - Check admin logged in
<?php
function isAdminLogin(){
$userId = 0;
$switchSessionName = 'adminhtml';
$currentSessionId = Mage::getSingleton('core/session')->getSessionId();
$currentSessionName = Mage::getSingleton('core/session')->getSessionName();
//if ($currentSessionId && $currentSessionName && isset($_COOKIE[$currentSessionName])) {
if(isset($_COOKIE[$switchSessionName])){
$switchSessionId = $_COOKIE[$switchSessionName];
$this->_switchSession($switchSessionName, $switchSessionId);
$user = Mage::getModel('admin/session')->getUser();
if($user){
$userId = Mage::getModel('admin/session')->getUser()->getId();
}
$this->_switchSession($currentSessionName, $currentSessionId);
}
//}
return $userId;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment