function nusoapclient::UpdateCookies in Salesforce Suite 5
Same name and namespace in other branches
- 5.2 includes/nusoap.php \nusoapclient::UpdateCookies()
* updates the current cookies with a new set * *
Parameters
array $cookies new cookies with which to update current ones: * @return always return true * @access private
1 call to nusoapclient::UpdateCookies()
- nusoapclient::send in includes/
nusoap.php - send the SOAP message
File
- includes/
nusoap.php, line 7212
Class
- nusoapclient
- nusoapclient higher level class for easy usage.
Code
function UpdateCookies($cookies) {
if (sizeof($this->cookies) == 0) {
// no existing cookies: take whatever is new
if (sizeof($cookies) > 0) {
$this
->debug('Setting new cookie(s)');
$this->cookies = $cookies;
}
return true;
}
if (sizeof($cookies) == 0) {
// no new cookies: keep what we've got
return true;
}
// merge
foreach ($cookies as $newCookie) {
if (!is_array($newCookie)) {
continue;
}
if (!isset($newCookie['name']) || !isset($newCookie['value'])) {
continue;
}
$newName = $newCookie['name'];
$found = false;
for ($i = 0; $i < count($this->cookies); $i++) {
$cookie = $this->cookies[$i];
if (!is_array($cookie)) {
continue;
}
if (!isset($cookie['name'])) {
continue;
}
if ($newName != $cookie['name']) {
continue;
}
$newDomain = isset($newCookie['domain']) ? $newCookie['domain'] : 'NODOMAIN';
$domain = isset($cookie['domain']) ? $cookie['domain'] : 'NODOMAIN';
if ($newDomain != $domain) {
continue;
}
$newPath = isset($newCookie['path']) ? $newCookie['path'] : 'NOPATH';
$path = isset($cookie['path']) ? $cookie['path'] : 'NOPATH';
if ($newPath != $path) {
continue;
}
$this->cookies[$i] = $newCookie;
$found = true;
$this
->debug('Update cookie ' . $newName . '=' . $newCookie['value']);
break;
}
if (!$found) {
$this
->debug('Add cookie ' . $newName . '=' . $newCookie['value']);
$this->cookies[] = $newCookie;
}
}
return true;
}