Question

I have stored a variable in register by Mage::register('captcha', $var); in helper. And in the controller i tried to retrieve the variable by using Mage::registry('captcha'); But i dont getting any values here. Please help me to solve this.

Was it helpful?

Solution

In your helper file create a function like below :

public function getCaptcha(){
    $var = 'myValue123';
    Mage::register('varun', $var);
    return Mage::registry('varun');
}

In your controller function:

$registryValue = Mage::helper('yourModule')->getCaptcha();
echo registryValue ; //prints myValue123

Hope it helps !!!

OTHER TIPS

It's look like syntax is right. Please first try to set some static value like $var="test"

Mage::register('captcha', $var);

after that got this value in controller.

Mage::registry('captcha');

if you got this value test then i think you have problem with $var in your helper.

Let me know if you have any problem

'captcha' is already in use, so magento never set your data in registry. Change the name, for example 'captcha1'

Mage::register('captcha1', $var);
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top