Magento 2 Extensions, Themes & Services

Sonice Best Responsive Magento 2 Theme

Magento 2 – Get current logged in customer details

In this blog post, we will see how to retrieve currently logged in customer details in Magento 2.

Sonice Best Responsive Magento 2 Theme

We can retrieve the currently logged in customer details using an instance of \Magento\Customer\Model\Session model through constructor. After initialization of model instant, we need to store instantiated object into protected variable like $customerSession. Session model contains so many methods related to customer and we can use this methods to retrieve customers details. Below are some of the methods.

  1. isLoggedIn()
  2. getCustomerId()
  3. getCustomerGroupId()
  4. getCustomer()
  5. getCustomerData()

Download Free New Order Notification Extension

We can call this methods as shown below.

You can use above code snippet to get current logged in customer details. That’s it. Enjoy!!

Mahendra Paladiya
Mahendra is a Web Developer whose passions includes web development, technical blog writing, and database management. His passion for web development pushed him into learning how to handle different platforms like Core PHP, Magento, Prestashop, WordPress, CodeIgniter, CakePHP and Oracle.


  1. Anthony Arnett

    April 20, 2016 at 7:59 am

    helpful post…can you please share code to get admin user details or session in magento 2.

  2. Its not working after cache enabled.

Leave a Reply

Your email address will not be published.



© 2019 Magewallet

Theme by Anders NorenUp ↑