Back to Top

How to use session in Magento

session in Magento

After few days,I am back again with my new quick article release. Today we will continue with Magento article series and i am going to explain how you can set, get and unset session into a magento.

It’s pretty simple, just you have to have an idea about it. First time When i wanted to set, i also think once is it difficult but no its quite simple in Magento

Let’s start with understanding it

To set a Magento session variable:


To get a Magento session variable value:

$Data = Mage::getSingleton('core/session')->getVariableName();

To unset a Magento session variable:


NOTE: Replace ‘VariableName’ with any desire text you want but ‘set’, ‘get’ and ‘uns’ prefixes are required.

That’s it.Now you have ‘set’, ‘get’ and ‘uns’ your session variables into Magento.

Thanks for reading and feel free to share your thoughts! Don’t Forget to Follow us on Twitter or Subscribe us to Get the Latest Updates.

Comments (1)

  1. Mage::getSingleton(‘core/session’)->setYourVariableName(‘value here’);

    Suppose we have some value say $name then i can save that value in session in magento in the following way.
    //YourVariableName is session variable name that we will also use to retrieve session value

    To retrieve variable value of session in magento use the below code.


    More details can be found at

Leave a Reply

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

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Most Popular Posts

PHP Encapsulation with simple example

Posted on 2 years ago


How dialog error message works in xCart?

Posted on 5 years ago


Introduction to PDO in PHP

Posted on 3 years ago


GoTo statement in PHP

Posted on 7 years ago


Hello world

Updated 1 week ago

Nick Carter

In depth Understanding of Laravel Core

Updated 2 months ago


ECMAScript 6 New Features – 2

Updated 1 year ago


The Reader’s Poll – June 2015

Posted on 4 years ago


The Reader’s Poll – August 2014

Posted on 4 years ago


The Reader’s Poll – June 2014

Posted on 5 years ago


The Readers’ Poll – May 2014

Posted on 5 years ago


The Readers’ Poll – August 2013

Posted on 5 years ago