I've a helper and in the __construct() something like:

public function __construct(
        Context $context,
        \Magento\Customer\Model\Session $customerSession

        $this->_customerSession = $customerSession;


he problem is when I can the $_customerSession object data it's empty, even though I've logged in.

It seems the session is instantiated at a later point in the process, because if I call the customer\Session object in a page Model or block it works fine. In fact, the whole store works as expected. I can see the logged in welcome message at the top right bar, add products to cart, login.

Thecode above is dispatched in the event


How do I make sure the session is loaded or how do I know when it's loaded?

  • have add use \Magento\Customer\Model\Session on that class
    – Amit Bera
    Feb 10, 2016 at 7:05
  • 1
    @AmitBera, I've added it, But I don't see why this could have been be the issue. I can access the class, but the problem is that it's not populated with data.
    – Filipe Sá
    Feb 10, 2016 at 15:24
  • Did you ever find a solution? Jun 29, 2016 at 9:39
  • @LM_Fielding No.
    – Filipe Sá
    Jul 1, 2016 at 15:20

1 Answer 1


I've run into the problem too. The problem occurs when cache is enabled.

Please see https://github.com/magento/magento2/issues/2010

Block with Cachable=false not rendered on product view page

  • How did you get around it? I'm considering adding a child block in my layout so I can access in my block class? Jun 29, 2016 at 9:39

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.