magento2 icon indicating copy to clipboard operation
magento2 copied to clipboard

Impossible to retreive the customer id of the session in an external script

Open torresl opened this issue 13 years ago • 1 comments

I created an external script test.php of Magento But, i don' t succeed to retreive the customer id of the session. This cript runs well in dev 39 version but not in dev 41 version. the script is as follows : "require_once 'app/bootstrap.php';

/* Store or website code */

To test, firstly, i authentificate a user via Magento. Secondly, i launch the script test.php. But the customer id isn' t displayed.

Thanks to explain how to retreive session customer data in an erternal script ? . $mageRunCode = isset($_SERVER['MAGE_RUN_CODE']) ? $_SERVER['MAGE_RUN_CODE'] : ''; /* Run store or run website _/ $mageRunType = isset($_SERVER['MAGE_RUN_TYPE']) ? $SERVER['MAGE_RUN_TYPE'] : 'store'; / Additional local.xml file from environment variable */ $options = array(); if (!empty($_SERVER['MAGE_LOCAL_CONFIG'])) { $options['local_config'] = $_SERVER['MAGE_LOCAL_CONFIG']; }

// Mage::init($mageRunCode, $mageRunType); Mage::app($mageRunCode, $mageRunType);

$val= Mage::getSingleton('Mage_Customer_Model_Session')->getCustomer();

$customer_id = Mage::getSingleton('Mage_Customer_Model_Session')->getCustomerId() ; $customer_name = Mage::getSingleton('Mage_Customer_Model_Session')->getCustomer()->getName();

echo $customer_id;

" To test, firstly, i authentificate a user via Magento. Secondly, i launch the script test.php. But the customer id isn' t displayed.

Thanks to explain how to retreive session customer data in an erternal script ? .

torresl avatar Feb 11 '13 00:02 torresl

I guess @mage2-team closed this because it is more a support question. @keniosor Maybe try asking the question on http://magento.stackexchange.com/

amenk avatar Feb 20 '13 08:02 amenk