Skip to content

Commit

Permalink
Fix for random failed authentication because of the old session cooki…
Browse files Browse the repository at this point in the history
  • Loading branch information
djaho committed Dec 9, 2018
1 parent 044dd5b commit 12d9461
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions phpListRESTApiClient.php
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ public function __construct($url, $loginName, $password, $secret = '')
*
* @return string result of the CURL execution
*/
private function callApi($command, $post_params, $decode = true)
private function callApi($command, $post_params, $decode = true, $newSession = false)
{
$post_params['cmd'] = $command;

Expand All @@ -95,6 +95,7 @@ private function callApi($command, $post_params, $decode = true)
curl_setopt($c, CURLOPT_POSTFIELDS, $post_params);
curl_setopt($c, CURLOPT_COOKIEFILE, $this->tmpPath.'/phpList_RESTAPI_cookiejar.txt');
curl_setopt($c, CURLOPT_COOKIEJAR, $this->tmpPath.'/phpList_RESTAPI_cookiejar.txt');
curl_setopt($c, CURLOPT_COOKIESESSION, $newSession); // Fix for random failed authentication
curl_setopt($c, CURLOPT_HTTPHEADER, array('Connection: Keep-Alive', 'Keep-Alive: 60'));

// Execute the call
Expand Down Expand Up @@ -123,7 +124,7 @@ public function login()
);

// Execute the login with the credentials as params
$result = $this->callApi('login', $post_params);
$result = $this->callApi('login', $post_params, true, true);
return $result->status == 'success';
}

Expand Down

0 comments on commit 12d9461

Please sign in to comment.