0

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.

1 Answer 1

2

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));
1
  • its not working Oct 20, 2015 at 5:02

Your Answer

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

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