I seem to have exhausted every example on google and stackoverflow. Please could someone tell me if this is even possible?
My script is in a folder along side the magento install. eg.
/var/www/app
/var/www/skin
/var/www/myCustomScript
I'm trying grab the current logged in admin id.
One of many examples I have tried.
require_once ("/var/www/app/Mage.php");
umask(0);
Mage::app();
$user = Mage::getSingleton('admin/session');
$userId = $user->getUser()->getUserId();
echo $userId;
What is the calling context? If you are trying to initialize the session from a context other than the browser which has the adminhtml cookie, you're going to have a bad time. If this is in a standalone script you will need to login via curl.
<?php
require_once ("app/Mage.php");
umask(0);
Mage::app();
Mage::getSingleton('core/session',array('name'=>'adminhtml'));
$user = Mage::getSingleton('admin/session');
$userId = $user->getUser()->getUserId();
echo $userId;
?>
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.