I'm using Magento And I have the Problem to access customer session data I set in different controllers. I found out, that Magento generates two session files (in var/session/) when I load two different controllers of my own modules where I set data to the “customer/session”! So when I load content over the one controller, then I get the one customer session data from the first session file and when I load a cms page or the other controller I get the data of the other session file! How can that be? I’m using the same browser all the time. Why does Magento think that there are two different users and generates two different customer session files when I load a different controller??? Additional I don’t work at this time with logged in customers...it’s all the time the guest customer session.

Has anybody any idea?


I checked the difference between the user of the different sessions by logging the session id and the differences of my controller classes. I found out that I used in one controller the “_construct” function to set some helper variables. And when I removed this usage Magento uses the other “correct” session. with the _construct, it used the other session id. But I don’t know why. Has anybody an Idea?

  • can you share some of the relevant code? Also are you calling the parent constructor in your controller? Nov 1, 2013 at 17:33
  • It's a standard controller class in my modules. When I set the class variable like this example: class MyCompany_MyModule_IndexController extends Mage_Core_Controller_Front_Action { protected $customerSession; public function _construct() { $this->customerSession = Mage::getSingleton('customer/session); } public function indexAction() { ... } ... } then Magento creates a new customer session and everything that is loaded by this controller uses this session. I didn't call the parent _construct because this does nothing. Nov 2, 2013 at 13:25
  • I don't really need to set the variable by _construct and did it on another way now, but I don't understand why magento behaves like that. Has somebody else this behavior when he calles the "_construct" function in a controller? Nov 2, 2013 at 13:29

1 Answer 1


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]

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.