I'm adding products to the cart using an ajax call. Inside the ajax responder I have the initial code.
Mage::app();
Mage::getSingleton('core/session', ['name' => 'frontend']);
If a user is not logged in it adds the products to the cart with no problems, but if a user is logged in, the second line causes the user to log out. Leaving the store in a logged out state with the last product added to the cart. Do I need to do anything to preserve the users session?
1 Answer 1
I found out the described behavior can happen if there's sessions from unstable code. After clearing the browser cache it works perfectly.
preDispatchinsideMage_Core_Controller_Varien_Actionclass. That is how Magento initializes the sessions. You might need to do the same somehow.