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.

2
  • 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 Dec 6, 2015 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 magento.stackexchange.com/questions/86674/… Dec 6, 2015 at 22:29

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.