diff --git a/WebDriver.php b/WebDriver.php index ac244d6..91acb7e 100644 --- a/WebDriver.php +++ b/WebDriver.php @@ -82,7 +82,7 @@ public static function WaitUntil($callback, $parameters, $expected) { return $actual; } - public static function Curl($http_type, $full_url, $payload = null, $escape_payload = true) { + public static function Curl($http_type, $full_url, $payload = null, $escape_payload = true, $cookies = array()) { $curl = curl_init($full_url); curl_setopt($curl, CURLOPT_CUSTOMREQUEST, $http_type); curl_setopt($curl, CURLOPT_RETURNTRANSFER, TRUE); @@ -99,6 +99,10 @@ public static function Curl($http_type, $full_url, $payload = null, $escape_payl } curl_setopt($curl, CURLOPT_POSTFIELDS, $payload); } + if (!empty($cookies)) { + $cookie_string = http_build_query($cookies, '', '; '); + curl_setopt($curl, CURLOPT_COOKIE, $cookie_string); + } WebDriver::LogDebug($http_type, $full_url, $payload); $full_response = curl_exec($curl); WebDriver::LogDebug($full_response);