Question

In module's helper Template.php I'm setting session variable using below code

public function getCategoryAddtoLinksIcons($_product, $_compareUrl, $wrapperClasses = '')
{
    $html = '';

    if (Mage::helper('wishlist')->isAllow())
    {           
        $url = Mage::helper('wishlist')->getAddUrl($_product);
        if(isset($url)){
            Mage::getSingleton('core/session')->setWishlistUrl($url);
        }
        $html .= '
        <li><a class="link-wishlist" onclick=socialLogin()>
                <span class="2 icon ib ic ic-heart"></span>
        </a></li>';
}
if (!empty($html))
    {
        return '<ul class="add-to-links clearer ' . $wrapperClasses .'">' . $html . '</ul>';
    }
    return $html;
}

and doing an ajax request to controller function where retriving session variable and unsetting it using

$wishlist_url = Mage::getSingleton('core/session')->getWishlistUrl();
Mage::getSingleton('core/session')->unsWishlistUrl(); 
Mage::log($wishlist_url, null, 'session.log');

But still I see, next time variable is set. Do I need to give timing also while setting/destroying session variable?

Was it helpful?

Solution

If you want to check, if this session variable is set, change

Mage::log($wishlist_url, null, 'session.log');

to

Mage::log(Mage::getSingleton('core/session')->getWishlistUrl(), null, 'session.log');
Licensed under: CC-BY-SA with attribution
Not affiliated with magento.stackexchange
scroll top