views:

26

answers:

1

Hi

Am developing a public site that uses the Zend_Http_Client to access remote logic.Is there a property/way in the Client adapter that I could set the remote address of the user browsing the site?

Currently am using this workaround which combines both remote address and remote useragent.

$client = new Zend_Http_Client();       
$client->setConfig(array(                       
    'useragent' => 'Get Remote Address'.'Get User Agent',       
)); 

Is there a specific property for remote address?

A: 

From any Zend_Controller_Action method you can retrieve the user's remote address as follows:

$ip = $this->getRequest()->getServer('REMOTE_ADDR');

If you're not in a Controller, you can use the following assuming the Front Controller was used:

$ip = Zend_Controller_Front::getInstance()->getRequest()->getServer('REMOTE_ADDR');

And finally - these methods are just wrappers for the SERVER superglobal:

$ip = $_SERVER['REMOTE_ADDR'];

Substitute REMOTE_ADDR with HTTP_USER_AGENT to get the user agent.

David Caunt
That I already have.The issue is how to pass that value IN the Zend_Http_Client adapter so that on the server I can comfortably retrieve the remote address in the REMOTE_ADDR variable instead of having the value in the HTTP_USER_AGENT variable.
davykiash
Oh, sorry, I misread the question! This is not possible with PHP.
David Caunt
I thought so too.Thanks
davykiash