Just I want to append array value in magento session data

    Mage::getSingleton( 'core/session' )->setData( 'createArrayDefault', array(3));
    Mage::getSingleton( 'core/session' )->setData( 'createArrayDefault', array(2));

print_r(Mage::getSingleton( 'core/session' )->getData('createArrayDefault'));

It displays array(0=>2) and override 3value from array
But I want this array(0=>2,0=>3);

When I print magento session data and print,it overrides array 3 value but I want both values in session data.How to append values in session data.


Setting data to your session:

$session = Mage::getSingleton('core/session');
$session->setData('createArrayDefault', array(3));

If you need later append values to that session data array:

$data = $session->getData('createArrayDefault'); 
$session->setData(array_merge(array(3), $data));

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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