You can check the Admin user is login or not using Magento 2 with Backend Session class.
Full path:
Magento\Backend\Model\Auth\Session
You need to create an injectable class in the __construct() method to check the admin user is login.
<?php
namespace Jesadiya\AdminUser\Model;
use Magento\Backend\Model\Auth\Session;
class IsLogin
{
/**
* @var Session
*/
private $backendSession;
public function __construct(
Session $backendSession
) {
$this->backendSession = $backendSession;
}
/**
* is login admin user
*
* @return bool
*/
public function isAdminLogin(): bool
{
return $this->backendSession->getUser() && $this->backendSession->getUser()->getId();
}
}
The output will be boolean based on the user login status.

One Reply to “How to check admin user is login in Magento 2?”