Thursday, 12 July 2012

Magento Set, Retrieve and Unset Session Variables

To set a Magento session variable:

$myValue = 'Hello World';
Mage::getSingleton('core/session')->setMyValue($myValue);


To Retrieve:

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


To Unset:

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


Note that 'MyValue' can be any text you want but 'set', 'get' and 'uns' prefixes are required.

No comments :

Post a Comment