Home » Magento

Magento: Get Set Unset Session

23 November 2009 5,667 views Popularity: 12% Share/Bookmark

email

Set a custom session with Variable Name ‘testing_magento’. The session value here is ‘hello’.
Mage::getSingleton('core/session')->setTestingMagento('hello');

Get session testing_magento
$test = Mage::getSingleton('core/session')->getTestingMagento();

Unset session
Mage::getSingleton('core/session')->setTestingMagento();

(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’)

Related posts:

  1. Magento: Send email easily using Zend_Mail
  2. Magento: How to get admin user id, name, username, email, etc?
  3. Magento: Block Controller Model Helper Override
  4. Session Handling in PHP
  5. Magento: How to run Magento code in an external website?
  6. Magento: Track Visitor’s Information
  7. Magento: Create Shopping Cart Price Rule Programmatically
  8. Magento: How to get most viewed products?
  9. jQuery: Grey out background and preview image as popup
  10. Magento: Send Transactional Email
  • http://www.phptechie.com/ php programming

    This is easy to understand the session value..
    i am understand to how to use session.
    Thanks.

  • http://www.shreeji-infosys.com Tarun Patel

    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.
    help 

  • 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.