I've been using PHP and curl to post sensitive data to my backend server. However, after the 2nd or 3rd post request, the post data doesn't seem to be clearing, instead, it appears to concatenate the old post data to the new data being sent.
Here is an example of how I am creating my request:
function Communicate($req, $postdata)
{
$curl = curl_init();
curl_setopt($curl, CURLOPT_URL, sprintf('%s%s', $this->server_uri, $req));
curl_setopt($curl,CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl, CURLOPT_POST, substr_count($postdata, '='));
curl_setopt($curl, CURLOPT_POSTFIELDS, $postdata);
$res = curl_exec($curl);
curl_close($curl);
unset($postdata);
$sfr = json_decode($res);
}
As you can see, it is fairly straightforward.
However, I am tracing the post request on my backend server and here is what I get:
1st request
Restful Function: ValidateUserByEmail Params: [email protected]&pass=foo
2nd request
Restful Function: GetRegionByUserId Params: [email protected]&pass=foo
The userid param of the 2nd request is supposed to be just 1. I can see that this is being set correctly before the curl_exec function is executed.