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:

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.
    Mage::getSingleton(‘core/session’)->setYourVariableName($name);
    //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.

    Mage::getSingleton(‘core/session’)->getYourVariableName();

    More details can be found at http://blogswindow.com/session-in-magento

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

AWS Cloud Database Migration Service

Posted on 7 years ago

Bhumi

The Readers’ Poll – June 2013

Posted on 11 years ago

Bhumi

How to set a Cookie in PHP

Posted on 12 years ago

Bhumi

How To Repair MySQL Table

Posted on 12 years ago

Bhumi