I have to set some additional data to currently logged in customer session. I have tried setting up new data in following way, but it doesn't work.
if (Mage::getSingleton('customer/session')->isLoggedIn()):
$customer = Mage::getSingleton('customer/session')->getCustomer();
$customer->setTest1("test1_value");
$customer->setTest2("test2_value);
endif;
If I print the session right after I set new data to session,I can see the data, but when I refresh the page, the data (test1 and test2) disappears. Note: I can see other regular customer session data.
Please suggest how the session data can be set to customer data session.
Looking forward, thank you in advance!
Best Answer
@Deepak Bjatta, I don't really see anything wrong with the code that you're showing, other than you could very well overwrite the data you're trying to set on each page load. Since the customer session has Varien_Object as an ancestor, you can do something like:
Re: Your ability to only print the data right after you set it, and not see the previously set data on page load...maybe you could show more code context? Maybe give the code above a shot and see if that does it for you?