This code snippet will check if a user is currently logged-in on magento backend.. this is useful if you want to integrate pages to your magento website, of course you must check if the user that is accessing the said page is an authenticated user of your magento administration.. that is where this code comes into play.. hope this helps
require_once '../app/Mage.php';
umask(0);
$app = Mage::app('default');
/* Init User Session */
Mage::getSingleton('core/session', array('name'=>'adminhtml'));
$session = Mage::getSingleton('admin/session');
if ($session->isLoggedIn()) {
/* do something if logged in */
echo "the user is logged in";
} else {
/* do something else if not logged in */
echo "the user is NOT logged in";
}
?>
require_once '../app/Mage.php';
umask(0);
$app = Mage::app('default');
/* Init User Session */
Mage::getSingleton('core/session', array('name'=>'adminhtml'));
$session = Mage::getSingleton('admin/session');
if ($session->isLoggedIn()) {
/* do something if logged in */
echo "the user is logged in";
} else {
/* do something else if not logged in */
echo "the user is NOT logged in";
}
?>
Great!!! it work.
ReplyDeletei created the gist: https://gist.github.com/jruzafa/9233299