If the wrong session is used, it is because the session_name is wrong. The session name is set in Mage_Core_Model_Session_Abstract_Varien::setSessionName()
.
But after a look on the Stacktrace, I have no idea, why overwriting _construct
or even __construct
should be a problem here:
#0 Mage_Core_Model_Session_Abstract_Varien->setSessionName(frontend) called at [app/code/core/Mage/Core/Model/Session/Abstract/Varien.php:111]
#1 Mage_Core_Model_Session_Abstract_Varien->start(frontend) called at [app/code/core/Mage/Core/Model/Session/Abstract/Varien.php:166]
#2 Mage_Core_Model_Session_Abstract_Varien->init(core, frontend) called at [app/code/core/Mage/Core/Model/Session/Abstract.php:84]
#3 Mage_Core_Model_Session_Abstract->init(core, frontend) called at [app/code/core/Mage/Core/Model/Session.php:42]
#4 Mage_Core_Model_Session->__construct(Array ([name] => frontend)) called at [app/code/core/Mage/Core/Model/Config.php:1348]
#5 Mage_Core_Model_Config->getModelInstance(core/session, Array ([name] => frontend)) called at [app/Mage.php:462]
#6 Mage::getModel(core/session, Array ([name] => frontend)) called at [app/Mage.php:476]
#7 Mage::getSingleton(core/session, Array ([name] => frontend)) called at [app/code/core/Mage/Core/Controller/Varien/Action.php:494]
#8 Mage_Core_Controller_Varien_Action->preDispatch() called at [app/code/core/Mage/Core/Controller/Front/Action.php:64]
#9 Mage_Core_Controller_Front_Action->preDispatch() called at [app/code/core/Mage/Core/Controller/Varien/Action.php:408]
#10 Mage_Core_Controller_Varien_Action->dispatch(view) called at [app/code/core/Mage/Core/Controller/Varien/Router/Standard.php:250]
#11 Mage_Core_Controller_Varien_Router_Standard->match(Mage_Core_Controller_Request_Http Object ([] => /test.html,[] => ,[] => /test.html,[] => ,[] => ,[] => Array (),[] => catalog,[] => ,[] => Mage_Catalog,[] => ,[] => Array (),[] => Array ([0] => _GET,[1] => _POST),[] => /catalog/product/view/id/21,[] => ,[] => ,[] => catalog/product/view/id/21,[] => Array ([id] => 21),[] => ,[] => Array ([rewrite_request_path] => test.html),[] => 1,[] => catalog,[] => module,[] => product,[] => controller,[] => view,[] => action)) called at [app/code/core/Mage/Core/Controller/Varien/Front.php:176]
#12 Mage_Core_Controller_Varien_Front->dispatch() called at [app/code/core/Mage/Core/Model/App.php:354]
#13 Mage_Core_Model_App->run(Array ([scope_code] => ,[scope_type] => store,[options] => Array ())) called at [app/Mage.php:683]
#14 Mage::run(, store) called at [index.php:87]
Magento 2 REST can not distinguish between authenticated and anonymous customers. Web services ACL is applied for admin users only. All customers are anonymous for REST services.
You can create such REST service if you want but you need to authenticate customers by yourself (using \Magento\Customer\Model\Session
, for example). Of course, REST requests should contain PHPSESSID cookie for appropriate session in HTTP headers.
Best Answer
Finally got the solution, i am trying my best to explain it.
so here's how Magento works !!
Magento gets the customer data with passing anything except token value in API call.
In between magento calls some API related controllers for the same
in this API call magento get customer data based on token.
Based on API url
url="/V1/customers/me"
magento calls function fromMagento calls In-between call of dispatch function.
And this
resolve()
function callsoverride()
functionand
overide()
function callsgetOverriddenValue()
functiongetOverriddenValue()
callsParamOverriderInterface
".../me/..."
route, the route should use only user information specific to the"/customers/me/addresses"
route, the service method"getAddresses($customerId)"
, but in thewebapi.xml
, the $customerId parameterand for business logic of this function is in file -
So this is how Magento get Customer Id between API calls !!
Another solution