Breaking News
Home / Magento / How to set, get & delete Session on Magento 1x

How to set, get & delete Session on Magento 1x

1.  Magento 1x Set a new session: Here is the example of it.
Mage::getSingleton(‘core/session’)->set{YOUR SESSION NAME}({SESSION VALUE});
Example :
$Value =’test’;
Mage::getSingleton(‘core/session’)->setName($Value);

*** if you use phtml/controller/model of magento 1x there you can use Mage:: function if you use a single file on root of you magento site then you need to add some functionality for call Mage::. Learn more by here.

#example
$Value ='test';
Mage::getSingleton('core/session')->setName($Value);

2.  Magento 1x Get Data from session:
Mage::getSingleton(‘core/session’)->get {YOUR SESSION NAME}();

$getSession =Mage::getSingleton('core/session')->getName();

3.  Magento 1x Delete session:
Mage::getSingleton(‘core/session’)->uns{YOUR SESSION NAME}();

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

Hits: 6

Leave a Reply