Hello Magento Friends,

Today I am here with the new topic, How to Get User Information Inside of Controller in Magento 2. Have you reviewed our previously published blog? If not, check it out now. How To Disable System Configuration Field Programmatically in Magento 2.

Controllers are an important part of MVC flow. They are responsible for a specific URL or group of URLs. Magento 2 admin can get user data inside the controller. User sessions can be obtained inside the controller to redirect customers who are not logged in. Let’s see how it works.

Steps to Get User Information Inside of Controller in Magento 2:

Step 1: Move to the below path

app\code\Vendor\Extension\Controller\Index\Custom.php

And, add this code

That’s it!

Conclusion:

This way you can Get User Information Inside of Controller in Magento 2. In case of any issues, reach me via the comment box. See you again with the next solution, till then stay connected with us!

Happy Coding!

Click to rate this post!
[Total: 4 Average: 5]