By looking at Mage_Core_Model_Session_Abstract class in Magento, you can easily set, retrieve, and unset session variables. So if you’re planning to code related in session, use the built in code of magento instead of hardcoding it.
Here are some examples:
1. To set Magento Session
2. To retrieve Session Variables
3. To unset
Important: Please note that "SessionName" in unsSessionName, getSessionName, and setSessionName can be any text you want / or simply it refers to the name of the session variable. However, the prefixes 'uns', 'set', and 'get' are required.
1. To set Magento Session
$yourSessionValue = 'session Value'; Mage:getSingleTon('core/session')->setSessionName($yourSessionValue);
2. To retrieve Session Variables
Mage:getSingleTon('core/session')->getSessionName();
3. To unset
Mage::getSingleton('core/session')->unsSessionName();
Important: Please note that "SessionName" in unsSessionName, getSessionName, and setSessionName can be any text you want / or simply it refers to the name of the session variable. However, the prefixes 'uns', 'set', and 'get' are required.
1 comments:
Thanks dude! I'm planning to use hardcoding if I didn't saw your post. :D
Post a Comment