Suppose I want access a varible one file to another file through session in magento.So please don’t use $_SESSION varible for that in magento.You just use the magento function for session like setSession(),getSession() and unsetSession().Magento uses great methods called setter and getter.So on that you can set and get your variable.

You just set a variable in file through session like PHP and acesss that on onther file on session.So there different methods available in magento for doing that.Please check below details

How set get unsetsession in magento

.I have a variable called $jyoti having value ‘testing session’.

that is $jyoti = ‘testing session’;

Set Session:

Mage::getSingleton('core/session')->setSessionVariable($jyoti);

Get Session:

$sessionVariable = Mage::getSingleton('core/session')->getSessionVariable();
echo $sessionVariable;

output will be ‘testing session’;

Unset Session:

Mage::getSingleton('core/session')->unsSessionVariable();
or
Mage::getSingleton('core/session')->setSessionVariable();

There is different session available in magento like customer and core for frontend and adminhtml for backend.
for example:

Mage::getSingleton('core/session')->setSessionVariable();
Mage::getSingleton('customer/session')->setSessionVariable();
Mage::getSingleton('adminhtml/session')->setSessionVariable();
How set get unsetsession in magento
Tagged on:     

Leave a Reply

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