zend_http_client browser caching issue

439 views Asked by At

I'm trying to access an https site by passing the username and password into the code, however, the website is denying me access due to 'browser caching issue', can someone help please? here is the code:

$client = new Zend_Http_Client();

$client->setUri('https://www.example.com');
$client->setParameterPost(array(
    'username' => 'username',
    'password' => 'password'
));


$client->request(Zend_Http_Client::POST);
$response = $client->request();

echo $response->getBody();
2

There are 2 answers

2
shevron On

Why are you calling $client->request() twice? You probably should call it one.

In addition, the reason could be specific to the site (you did not specify which site it is). For example, many sites implement some kind of CSRF protection token or other security measure which will require you to first GET the log-in page, grab some hidden field value from it and re-send it in the log-in POST request. This is quite typical and I suggest you use Chrome developer tools, Firebug or a similar tool to manually submit the log-in form from your browser, and check which other form values are sent on log-in beyond just the username and the password.

1
user2045298 On

I sorted out the problem, the code is supposed to work but the site has a security hash that prevents me from accessing it that way.