8

Is it possible to store data in the Magento session or registry using the the observer function, with:

Mage::getSingleton('core/session')->setFoo('bar'); //Or 'customer/session', 'admin/session'

Or

Mage::register('foo', 'bar');

I tried to add

sesson_write_close();

But only managed to read session data.

10

For that when your observer will call then you can create the session and set the value of that.

you can set the session using set, getting value using get and unset session using uns.

Mage::getSingleton('core/session')->setMySessionVariable('MyValue'); 

$myValue = Mage::getSingleton('core/session')->getMySessionVariable();

echo $myValue;

To Unset the session

Mage::getSingleton('core/session')->unsMySessionVariable();
2

you can set by setter and get by better method of magento like:

 Mage::getSingleton('core/session')->setSessionVariable($jyoti);
 $sessionVariable = Mage::getSingleton('core/session')->getSessionVariable();
 echo $sessionVariable;

This depend upon the session fro which you are like to save you value into variable like :

 Mage::getSingleton('core/session')->setSessionVariable();
 Mage::getSingleton('customer/session')->setSessionVariable();
 Mage::getSingleton('adminhtml/session')->setSessionVariable();

For core session or admin or customer session.By the above code you set and get session value.

For more details please check the below link

Handel Magento session

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.