I am setting a session variable on an event triggered when the url have an extra variable name "pcode" with the following code.


Now when getting the session from one of template file with the following code..


*Edit:*Enable the log From back-end and checked

but I am getting nothing.

I also tried the same code by calling a model and also from calling an ajax function from the template but have the same results.


When I am getting the session value after setting get, it retrieves the value but in another template page, its have no value.

$request = $observer->getEvent()->getData('front')->getRequest();
        $pcode  = $request->pcode;
            //Mage::getModel(‘core/cookie’)->set('pcode', $pcode);

Edit: Enable the log From back-end and check in var/log/system.log file your value will logged or not.

1 Answer 1


you can set the session using set, getting value using get and unset session using uns.


$myValue  =  Mage::getSingleton(‘core/session’)->getMySessionVariable();

echo $myValue;

To Unset the session

  • I am using the same method but unable to get the session. what's wrong with my code??
    – Tariq Aziz
    Feb 5, 2014 at 7:08
  • check you got value in $pcode or not
    – Keyul Shah
    Feb 5, 2014 at 7:09
  • When I put the code echo Mage::getSingleton('core/session')->getPcode(); exactly after setting it, I am getting the value. however later in a template file, noting is retrieved.
    – Tariq Aziz
    Feb 5, 2014 at 7:12
  • means your session is expired some how
    – Keyul Shah
    Feb 5, 2014 at 7:13
  • No its not expired, I have modified the question, plz review.
    – Tariq Aziz
    Feb 5, 2014 at 7:20

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.