Magento 2 Check admin user logged or not
Magento 2 Check admin user logged or not– Sometimes we need to check the admin user login status ie. whether the admin user is logged in or not. Here in this article, we are going to explain how to check admin user login status.
Magento 2 Check admin user logged or not | Magento2 Example
You can use admin auth session to determine the admin user login status. Here is an example to check the admin login status –
Magento 2 Check admin user logged or not Example:
$objectManager = \Magento\Framework\App\ObjectManager::getInstance(); $adminSession = $objectManager->get('Magento\Backend\Model\Auth\Session'); if($adminSession->isLoggedIn()) { // Admin is logged do your stuffs here } |
We have used Magento\Backend\Model\Auth\Session to check the admin login staus. You can use object manager as above to check whether the admin user is login or not.
Advertisements