If you want to hide and show header with respect to customer login/logout
add this in body of file
app/design/frontend/vendor/theme/Magento_Theme/layout/default.xml
<referenceBlock name="header.links">
<block class="vendor\module\Block\Headerlinks" name="history-link" after="my-account-link">
<arguments>
<argument name="sortOrder" xsi:type="number">100</argument>
</arguments>
</block>
</referenceBlock>
and in file Headerlinks
add
<?php
namespace vendor\module\Block;
class Headerlinks extends \Magento\Framework\View\Element\Template
{
protected $customerSession;
/**
* Construct
*
* @param \Magento\Framework\View\Element\Template\Context $context
* @param \Magento\Customer\Model\Session $customerSession
* @param array $data
*/
public function __construct(
\Magento\Framework\View\Element\Template\Context $context,
array $data = [],
\Magento\Customer\Model\SessionFactory $customerSession
) {
parent::__construct($context, $data);
$this->customerSession = $customerSession;
}
/**
* Render block HTML
*
* @return string
*/
protected function _toHtml()
{
$customer = $this->customerSession->create();
if ($customer->isLoggedIn()) {
$link = '<li><a href="' . $this->getUrl('customer/account/') . '" title="Account & Security">Account & Security</a></li>';
$link .= '<li><a href="' . $this->getUrl('sales/order/history/') . '" title="Purchase History">Purchase History</a></li>';
return $link;
}
return;
}
}