Home » Magento23 November 2009

Magento: Get Set Unset Session

Here are code to Get, Set, and Unset Session in Magento.

Set session with variable Name ‘testing_magento‘. The session value here is ‘hello‘.


Get session ‘testing_magento’

$test = Mage::getSingleton(‘core/session’)->getTestingMagento();

Unset session


Note: 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’)

Hope it helps. Thanks.


Get New Post by Email

Find me on

FacebookTwitterGoogle+LinkedInRSS Feed
  • This is easy to understand the session value..
    i am understand to how to use session.

  • Thanx a Lot Buddy… You saved my lots of Time..

    Thanx again my Dear Friend for Good Post..!!

  • Sumantapati

    I use the code in index.php, but I am getting error
    “It is not safe to rely on the system’s timezone settings when use custom session variable….”

    How to solve this

  • Bhushanahirrao

    I am setting Session in One controller function and getting it in another controller function. But not working. Can u guide?

  • Jauharishashank

    According to me Mage::getSingleton(‘core/session’)->unsTestingMagento(); is used for unset

  • Anonymous

    Thanks for this. What is the difference between customer and core session? Which one should we use?

  • Jaimin

    in one file editting in frontend i change customer session to core session and then refresh the page now my admin can not open it’s shows only processing.

  • Evgenius

    Is there a way to initialize a frontend session (like customer/session) from within the Admin Panel? I need to determine if current admin is also logged in on frontend as some user.

  • Jitesh

    Hey Mukesh…Nice work !!!i got 2-3 more beneficial logic for magento from your blog…keeps bloging dude