Session is a way to preserve certain data across subsequent accesses.
Session enables you to build more customized applications and increase the appeal of your Magento store.
Here we will see how to use sessions in Magento.
Syntax
Mage::getSingleton('core/session')->set<SESSION_NAME>(<VARIABLE_NAME or VALUE>);
Example
<?php
$emailId = '[email protected]';
// Set value in session
Mage::getSingleton('core/session')->setEmailID($emailId);
?>
Syntax
Mage::getSingleton('core/session')->get<SESSION_NAME>();
Example
<?php
// Get session value
$emailIdValue = Mage::getSingleton('core/session')->getEmailID();
?>
Syntax
Mage::getSingleton('core/session')->uns<SESSION_NAME>();
Example
<?php
// Unset session value
Mage::getSingleton('core/session')->unsEmailID();
?>
Yo can use different sessions in frontend and backend as below.
Core Session : Mage::getSingleton('core/session')
Customer Session : Mage::getSingleton('customer/session')
Core Session: Mage::getSingleton('adminhtml/session')
With the help of above code you can use sessions In Magento easily.
If you face any problems or need our professional services, please email us at [email protected]
Never miss the latest offers, voucher codes and useful articles delivered weekly in your inbox.