i have tried through this method
public function isAdmin() {
$this->_coreSession->start();
echo $this->_coreSession->getMessage();
echo 'session test4';
exit;
}
protected $_session;
public function __construct(
\Magento\Framework\Model\Context $context,
\Magento\Backend\Model\Auth\Session $authSession
) { $this->_session = $authSession;
parent::__construct($context);
}
Use:-
$this->_session->isLoggedIn()
to check whether the admin is logged in or not.