BLOCK file :
namespace Test\Module\Block;
class testing extends \Magento\Framework\View\Element\Template
{
protected $customerSession;
public function __construct(
\Magento\Framework\View\Element\Template\Context $context,
\Magento\Customer\Model\Session $customerSession
) {
$this->customerSession = $customerSession;
parent::__construct($context);
}
public function customerIsLogin()
{
return $customerSession->isLoggedIn()
}
}
PHTML file :
echo $this->customerIsLogin();
?>