Magento Set, Retrieve and Unset Session Variables

To set a Magento session variable:

$myValue = 'Hello World';

To Retrieve:

$myValue = '';

To Unset:


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

10 responses to “Magento Set, Retrieve and Unset Session Variables”

  1. This wasn’t actually that helpful. At this point in the game I have a good handle on magic methods. But how do I mess with a session that’s not the one I’m currently in? I’m working with a swf and that doesn’t count as the same session apparently.

  2. Mage::getSingleton(‘core/session’)->setMyValue(123);

    calling the line above in a class extending Mage_Core_Block_Messages.

    __clone method called on non-object in


Leave a Reply

Your email address will not be published. Required fields are marked *