I have been trying to get adminhtml session by DI Magento\Backend\Model\Session but I get nothing.

Is it possible to get adminhtml session information from the storefront and vice versa?

1 Answer 1


Here is the way you can set or get the data which you want.

namespace Namespace\ModuleName\Model;

class MyCustomClass
     * @var \Magento\Backend\Model\Session
    protected $backendSession;

     * @var \Magento\Framework\Model\Context
    protected $context;

    public function __construct(
        \Magento\Backend\Model\Session $backendSession,
        \Magento\Framework\Model\Context $context
    ) {
        $this->backendSession = $backendSession;
        $this->context = $context;

    public function onSalesOrderCreditmemoRegisterBefore($observer)
         echo $this->backendSession->getVmaId();
  • I mean I need to have information about the currently logined administrator on the storefront. Anyway your solution does not work cause if I set some values from adminhtml controller to backend session, I still cannot get that value from backend session on front conrtroller. Jul 20, 2018 at 13:10
  • You can set this data in table or cookie as well. Jul 20, 2018 at 13:16
  • It is not right way. So I am interesting in only my question. Jul 20, 2018 at 13:52
  • @ManishGoswami stackoverflow.com/a/65968400/3690413 Jan 30, 2021 at 13:17

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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