3

I try get custommer is login. it not success. this is my code

protected $_customerSession;
public function __construct(
...
\Magento\Customer\Model\Session $customerSession,
....
){
...
$this->_customerSession = $customerSession;
...
}
 public function getCustommer()
    {           
         if ($this->_customerSession->isLoggedIn()) {   
            die('islogin');      
            return $this->_customerSession->getCustomer();
         }else{
             die('not login');
         }

    }

result not login any help. what wrong?

or also other ways to GetCustomer isLogin. please tell me.

xanka
  • 2,114
  • 6
  • 33
  • 65
  • Do not understand why this user get a -1 vote. I have the same issue. I have similar code and it works only in My Account but not on CMS Page. I suppose there is a trigger for the session somewhere or a bug – Sylvain Rayé Dec 06 '15 at 17:05
  • In my case, the problem is due to Full Page Cache and that the block is saved in cache. Using the answer of this post helps me http://magento.stackexchange.com/questions/86674/block-with-cachable-false-not-rendered-on-product-view-page/90130#90130 – Sylvain Rayé Dec 06 '15 at 22:29

0 Answers0