objectManager = \Magento\Framework\App\ObjectManager::getInstance(); $this->customerSession = $this->objectManager->get(\Magento\Customer\Model\Session::class); parent::__construct($context); } public function execute() { if($this->customerSession->isLoggedIn()) { $customer = $this->customerSession->getCustomer(); $response = array(); $response["email"] = $customer->getEmail(); $response["fullname"] = $customer->getName(); echo json_encode($response); exit; } else { echo null; exit; } } }