Saturday, September 17, 2011

Magento: Get Set Unset Session

Set a custom session with Variable Name ‘testing_magento’. The session value here is ‘hello’.
Mage::getSingleton('core/session')->setTestingMagento('hello');

Get session testing_magento
$test = Mage::getSingleton('core/session')->getTestingMagento();

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

(Use customer or core session in frontend. Use adminhtml session in the backend.)
Core Session:- Mage::getSingleton(‘core/session’)
Customer Session:- Mage::getSingleton(‘customer/session’)
Admin Session:- Mage::getSingleton(‘adminhtml/session’)

0 comments:

Post a Comment