5

I am using the redis_session for storing the back end cache and session with different db id's.

Now, the below code returns empty when using it in the custom module.

Mage::getSingleton('core/session', array('name' => 'frontend'));
Mage::getSingleton('customer/session')->getCustomer()->getId();

It is working fine with in core code(sales_order_history). The issue exists only in my custom module.

Please help.. Thanks in advance

2 Answers 2

3

It shouldn't have any consequence for your code on this level, whatever session backend you are using. Memcache, redis, file, database. Everything should work with this code.

Is it working, when you are using file? Have you checked the redis, that something (the right thing) is written?

Theoretically Magento is using the session backend transparently. Nothing for you to do, except configuring it.

2
  • Thank you for your reply. It is working fine with in core code( sales_order_history). The issue exists only in my custom module.
    – Phani Bob
    Jun 28, 2015 at 9:19
  • Are you sure, the session is already initialized? Jun 28, 2015 at 17:54
3

If your custom module is being fired before preDispatch - then the session can't be instantiated (because the area isn't defined yet).

The Alan Storm nails it here, http://alanstorm.com/magento_sessions_early

0

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.