How to get logged in customer data in Magento2?

  • author-img Nidhi
  • 6 years
How to get logged in customer data in Magento2

First you need to create a object instance:

?$om = \Magento\Framework\App\ObjectManager::getInstance();

After that:

    $customerSession = $om->get('Magento\Customer\Model\Session');
    if($customerSession->isLoggedIn()) {
        echo   $customerSession->getCustomer()->getId()."
";  // get Customer Id
        echo   $customerSession->getCustomer()->getName()."
";  // get  Full Name
        echo   $customerSession->getCustomer()->getEmail()."
"; // get Email Name
        echo   $customerSession->getCustomer()->getGroupId()."
";  // get Customer Group Id

Though, if you find difficult or need more clarity regarding this “How to” or would like to add some suggestions to this solution, do drop a comment below or query at Our certified Magento team will give you a positive solution to all your Magento related queries with positive ROI!

Free Webinar

Ready to start your eCommerce journey?

Get in Touch
Recent Posts

Ready to Get Started

Communication is the key for us to understand each other. Allow us to understand
your requirements or queries. Present us with an opportunity to serve you.

Fill out the form and out team will get back to you
within 24 hours

    Head Office

    1250 Pittsford Victor Road Ste 310
    Pittsford, NY 14534