Posting in the Magento forums has been disabled pending the implementation of a new and improved forum solution which should better serve the community.

For new questions please post at, the community-run support site for the Magento community. We will be providing updates on the new forum solution soon. For questions or concerns please email

Magento Forum

How to retreive session’ s customer in an external script from Magento2 ? 
Jr. Member
Total Posts:  8
Joined:  2011-06-01

After a customer authentication in Magento2 , i try to retreive the session in a external script, but no success :
the external script is :
require_once ‘app/bootstrap.php’;
$mageRunCode = isset($_SERVER[’MAGE_RUN_CODE’]) ? $_SERVER[’MAGE_RUN_CODE’] : ‘’;
$mageRunType = isset($_SERVER[’MAGE_RUN_TYPE’]) ? $_SERVER[’MAGE_RUN_TYPE’] : ‘store’;
Mage::init($mageRunCode, $mageRunType);
$sessiona= Mage::getModel(’Mage_Customer_Model_Session’);
echo var_export($sessiona);
The result is:
Mage_Customer_Model_Session::__set_state(array( ‘_customer’ => NULL, ‘_isCustomerIdChecked’ => NULL, ‘_persistentCustomerGroupId’ => NULL, ‘_skipSessionIdFlag’ => false, ‘_data’ => array ( ), ‘_hasDataChanges’ => false, ‘_origData’ => NULL, ‘_idFieldName’ => ‘id’, ‘_isDeleted’ => false, ))
If somebody knows how to retreive the session of a customer authenticated in an external script with Magento2, thanks to inform me how.

Magento Community Magento Community
Magento Community
Magento Community
Magento Community
Magento Community
Back to top