views:

167

answers:

2

Hi,

I am using Magento and tryin to save a value in session as follows in its index.php file, but value is not being retained.

$_SESSION['myvar'] = '1';

How do I do it?

Thanks

+2  A: 

Let's say you want to save the value "Hello world" to the "welcome message" variable in the session. The code would be :

$inputMessage = 'Hello World';
Mage::getSingleton('core/session')->setWelcomeMessage($inputMessage);

Now you want to echo the "welcome message" somewhere else in your code/site.

$outputMessage = Mage::getSingleton('core/session')->getWelcomeMessage();
echo $this->__($outputMessage);
vrnet
A: 

Not working. I have the following code and it stops at line "setWelcomeMessage"

if(isset($_GET["lang"]))
{
 Mage::getSingleton('core/session')->setWelcomeMessage($_GET["lang"]);
}
Ali

related questions