You can make custom helper in and can call in app/design/frontend/theme/themename/Magento_Theme/templates/html/header.phtml
like below:
$helper = $this->helper('Vendor\Module\Helper\Header'); and you can call like:
$helper->isCustomerLoggedIn();
In Vendor\Module\Helper\Header Class you can make one method for check customer is logged in or not
<?php namespace Vendor\Module\Helper; class Header extends \Magento\Framework\App\Helper\AbstractHelper { public function __construct( \Magento\Framework\App\Helper\Context $context, \Magento\Customer\Model\Session $customerSession ) { $this->_customerSession = $customerSession; parent::__construct($context); } public function isCustomerLoggedIn(){ return $this->_customerSession->isLoggedIn(); }
}