Here is a simple way to get IP Address in Magento 2
protected function getIpAddress() { $om = \Magento\Framework\App\ObjectManager::getInstance(); $obj = $om->get('Magento\Framework\HTTP\PhpEnvironment\RemoteAddress'); $ip = $obj->getRemoteAddress(); return $ip; }
Link: https://www.polacin.com/magento2/how-to-get-ip-address-in-magento-2/
No comments:
Post a Comment