cancel
Showing results for 
Search instead for 
Did you mean: 

Magento don't load customer from session with SID in url

Magento don't load customer from session with SID in url

Hi all,

In my magento installation I set the configuration "Use SID on frontend" to yes. But when I try to call a rest api that return customer data in session throught the SID parameter, it doesn't return anything. Magento not recognize the session of the user, returning false on 

Mage::getSingleton('customer/session')->isLoggedIn()

This is a piece my code:

 

$store_id=$this->getRequest()->getParam("storeid");
if(isset($store_id)){
Mage::app()->setCurrentStore($store_id);
}else{
http_response_code(400); // unauthorized
exit;
}

$session = Mage::getSingleton('customer/session');
if ($session->isLoggedIn()) {
$customer = $session->getCustomer();
$response = array();
$response["SID"] = Mage::getSingleton('core/session', array('name' => 'frontend'))->getSessionId();
$response['firstname'] = $customer['firstname'];
$response['lastname'] = $customer['lastname'];
$response['email'] = $customer['email'];
$response['user_id'] = (int)$customer['entity_id'];

 

I'm using magento version 1.9.3.6.

 

This is an example of call to my api:

https://magento.local/myapi/index/getCustomer?SID=m30m520uopgnplgvlh938j3k84&storeid=it_it

 

Thank you

1 REPLY

Re: Magento don't load customer from session with SID in url

@davidelitricoWhat is that you are trying to achieve? Use SID in frontend setting is for something else. For example you have multi-site setup and want to share cart or something similar.

 

Problem solved? Please give Kudos and accept answer as solution.

Thanks,
Tarandeep
Magento 2 Certified Solution Specialist (x2). Follow me on Twitter