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;
  }
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;
  }
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 ; }
sort out cookies for the current request

@param	array $cookies array with all cookies
@param	boolean $secure is the send-content secure or not?
@return	string for Cookie-HTTP-Header
@access	private
sort out cookies for the current request