1

How to terminate other administrator session in back-end

1

Simple we can get $sessionInfo \Magento\Security\Model\AdminSessionInfo */ and set status 0 for which $sessionId we want to terminate

public function destroySession($sessionId)
{
    /** @var  $sessionInfo \Magento\Security\Model\AdminSessionInfo */
    $sessionInfo = $this->adminSessionInfoFactory->create()->load($sessionId, 'session_id');

    try{

        $sessionInfo->getResource()->updateStatusByUserId(
            \Magento\Security\Model\AdminSessionInfo::LOGGED_OUT,
            $sessionInfo->getUserId(),
            [1],
            [],
            null
        );

    } catch (\Exception $e) {

    }

    return $this;
}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.