0

i have tried through this method

public function isAdmin() {
        $this->_coreSession->start();
        echo $this->_coreSession->getMessage();
        echo 'session test4';
        exit;
    }
Pramod
  • 1,464
  • 1
  • 11
  • 38
aich.khalid
  • 375
  • 1
  • 13

1 Answers1

1
 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.

Pramod
  • 1,464
  • 1
  • 11
  • 38
Tanmay
  • 790
  • 3
  • 14