Magento 2.x – Customer session not working – not getting customer logged in data


Hi there,

If you trying to get customer logged in data in your Magento 2 module, and for any reason this is not working, retriving null, or nothing ar all, this is mostly related with the enabled cache you are using.

To solve this out, you can proceed on two different ways.

Adding a piece of code in a block – even with cache enabled

Add cacheable=”false” in your xml

and below code would work directly on your block side:

 

Happy coding!!