function soap_transport_http::getCookiesForRequest in Salesforce Suite 5
Same name in this branch
- 5 includes/nusoap.php \soap_transport_http::getCookiesForRequest()
- 5 includes/nusoap.orig.php \soap_transport_http::getCookiesForRequest()
Same name and namespace in other branches
- 5.2 includes/nusoap.php \soap_transport_http::getCookiesForRequest()
- 5.2 includes/nusoap.orig.php \soap_transport_http::getCookiesForRequest()
* sort out cookies for the current request * *
Parameters
array $cookies array with all cookies: * @param boolean $secure is the send-content secure or not? * @return string for Cookie-HTTP-Header * @access private
2 calls to soap_transport_http::getCookiesForRequest()
- soap_transport_http::sendRequest in includes/
nusoap.php - soap_transport_http::sendRequest in includes/
nusoap.orig.php
File
- includes/
nusoap.orig.php, line 2983
Class
- soap_transport_http
- transport class for sending/receiving data via HTTP and HTTPS NOTE: PHP must be compiled with the CURL extension for HTTPS support
Code
function getCookiesForRequest($cookies, $secure = false) {
$cookie_str = '';
if (!is_null($cookies) && is_array($cookies)) {
foreach ($cookies as $cookie) {
if (!is_array($cookie)) {
continue;
}
$this
->debug("check cookie for validity: " . $cookie['name'] . '=' . $cookie['value']);
if (isset($cookie['expires']) && !empty($cookie['expires'])) {
if (strtotime($cookie['expires']) <= time()) {
$this
->debug('cookie has expired');
continue;
}
}
if (isset($cookie['domain']) && !empty($cookie['domain'])) {
$domain = preg_quote($cookie['domain']);
if (!preg_match("'.*{$domain}\$'i", $this->host)) {
$this
->debug('cookie has different domain');
continue;
}
}
if (isset($cookie['path']) && !empty($cookie['path'])) {
$path = preg_quote($cookie['path']);
if (!preg_match("'^{$path}.*'i", $this->path)) {
$this
->debug('cookie is for a different path');
continue;
}
}
if (!$secure && isset($cookie['secure']) && $cookie['secure']) {
$this
->debug('cookie is secure, transport is not');
continue;
}
$cookie_str .= $cookie['name'] . '=' . $cookie['value'] . '; ';
$this
->debug('add cookie to Cookie-String: ' . $cookie['name'] . '=' . $cookie['value']);
}
}
return $cookie_str;
}