Magento – How to get admin session(user) details on front side in Magento 2

backendmagento2session

In order to restrict front side access for some admin user i need currently logged in admin user details at front side.

I have tried to get the admin session details as per below but not getting details.

Variable: protected $_adminSession;

Model: Magento\Backend\Model\Auth\Session $adminSession

Function:

$this->_adminSession->hasUser() ? (int)$this->_adminSession->getUser()->getId() : null;

Above call gives me blank value.

If someone have idea regarding the same please share here.

Best Answer

This is not possible.
Frontend and backend are separate applications and use separate sessions.
It's the same thing as Magento 1.

Related Topic