How can I get the client\'s IP address in CakePHP? It\'d be $_SERVER[\'REMOTE_ADDR\']
in plain PHP.
I thought it\'s like all $_SERVER
vars
If you need to get the IP address from within a model, $this->request->getClientIp()
won't work, throwing:
Error: Call to a member function clientIp() on a non-object
Use Router::getRequest()->clientIp()
instead.
So basically, Router::getRequest()
can serve as a Model's replacement of the Controller's $this->request