write a cookie

@access	private
@param	array, cookie payload
@return  void
497389
protected function _set_cookie($payload = array())
	 {
		if ($this->config['enable_cookie'])
		{
			$payload = $this->_serialize($payload);

			// encrypt the payload if needed
			$this->config['encrypt_cookie'] and $payload = \Crypt::encode($payload);

			// make sure it doesn't exceed the cookie size specification
			if (strlen($payload) > 4000)
			{
				throw new \FuelException('The session data stored by the application in the cookie exceeds 4Kb. Select a different session storage driver.');
			}

			// write the session cookie
			if ($this->config['expire_on_close'])
			{
				return \Cookie::set($this->config['cookie_name'], $payload, 0, $this->config['cookie_path'], $this->config['cookie_domain'], null, $this->config['cookie_http_only']);
			}
			else
			{
				return \Cookie::set($this->config['cookie_name'], $payload, $this->config['expiration_time'], $this->config['cookie_path'], $this->config['cookie_domain'], null, $this->config['cookie_http_only']);
			}
		}
	}
914259
public static function writeArray($array)
    {
        $data = array();
        foreach ($array as $var=>$val) {
            if (is_array($val) && !is_object($val)) {
                $data[$var] = self::writeArray($val);
            } else {
                $data[$var] = self::writeArrayItem($val);
            }
        }
        return serialize($data);
    }
654431
public function addCookie($key, $value = null)
    {
        if (is_array($key)) {
            foreach ($key as $newKey => $newValue) {
                $this->addCookie($newKey, $newValue);
            }
        } else {
            $value = preg_replace('/(;\s*path=.+)/', '', $value);

            if (is_numeric($key)) {
                $this->cookies[] = $value;
            } else {
                $this->cookies[] = "$key=$value";
            }
        }
    }
165061
function set_cookies(url, cookies) {
	if(is.string(cookies)) {
		cookies = [cookies];
	}
	debug.assert(url).is('object');
	debug.assert(url.host).is('string');
	debug.assert(cookies).is('array');

	//debug.log('Saving cookies for host = ', url.host);

	if(!is.array(_cookies[url.host])) {
		_cookies[url.host] = cookies;
		//debug.log('Saved new cookies as: ', _cookies[url.host]);
		return;
	}

	var tmp = {};

	function save_cookie(cookie) {
		var i = cookie.indexOf('=');
		var name = cookie.substr(0, ((i >= 1) ? i : cookie.length));
		tmp[name] = cookie;
	}

	ARRAY(_cookies[url.host]).forEach(save_cookie);
	ARRAY(cookies).forEach(save_cookie);

	_cookies[url.host] = ARRAY(Object.keys(tmp)).map(function(key) { return tmp[key]; }).valueOf();

	//debug.log('Saved new cookies as: ', _cookies[url.host]);
}
200703
public function setCookie($key, $value)
    {
        $this->_cookies[$key] = $value;
        $this->setopt(CURLOPT_COOKIE, http_build_query($this->_cookies, '', '; '));
    }
1016504
public function setInput(&$post, &$cookie, &$files, &$put, &$delete, &$data)
    {

        $this->post = $post;
        $this->cookie = $cookie;
        $this->files = $files;
        $this->put = $put;
        $this->delete = $delete;
        $this->data = $data;
    }
1346370
protected function writeCookie(array $preferences)
    {
        $data     = implode(',', $preferences);
        $lifetime = time() + self::$preferenceLifetime;
        $path     = '/';
        $server   = explode('.', $_SERVER['SERVER_NAME']);
        $domain   = '';

        for ($i = 2; $i > 0; --$i) {
            $domain = '.'.$server[$i].$domain;
        }

        // Store preferences in cookie and return result
        return setcookie(self::$identifier, $data, $lifetime, $path, $domain);
    }
535418
public function writeCData($value)
    {
        if (is_array($value)) {
            foreach ($value as $attrValue) {
                $this->context->writeCData($attrValue);
            }
        } else {
            $this->context->writeCData($value);
        }
    }
704656
private function sendHeaders() {
        if (!headers_sent()) {
            http_response_code($this->statusCode);
            foreach ($this->headers as $header) {
                header($header);
            }
            foreach ($this->cookies as $cookie) {
                call_user_func_array("setcookie", $cookie);
            }
        }
    }
236115
public static function send_cookie(
		$name, $value='', $expire=0, $path='', $domain='',
		$secure=false, $httponly=false
	) {
		if (!isset($_COOKIE))
			$_COOKIE = [];
		if ($expire > 0) {
			$_COOKIE[$name] = $value;
			return;
		}
		if (isset($_COOKIE[$name]))
			unset($_COOKIE[$name]);
	}
887436
public function cookies(array $cookies = null): HttpRequest
    {
        if ($cookies === null) {
            $cookies = $_COOKIE;
        }
        foreach ($cookies as $name => $value) {
            $this->cookie($name, $value);
        }

        return $this;
    }
1291186
public function copyFromArray(array &$array)
    {
        parent::copyFromArray($array);

        // serviceApiKey
        $this->setServiceApiKey(
            LanguageUtility::getFromArray('serviceApiKey', $array));

        // clientId
        $this->setClientId(
            LanguageUtility::getFromArray('clientId', $array));

        // subject
        $this->setSubject(
            LanguageUtility::getFromArray('subject', $array));

        // latestGrantedScopes
        $this->setLatestGrantedScopes(
            LanguageUtility::getFromArray('latestGrantedScopes', $array));

        // mergedGrantedScopes
        $this->setMergedGrantedScopes(
            LanguageUtility::getFromArray('mergedGrantedScopes', $array));

        // modifiedAt
        $this->setModifiedAt(
            LanguageUtility::getFromArray('modifiedAt', $array));
    }
680097
function setAllCookies(array $cookies)
    {
        // Must do this for PHP 5.3 compat.
        $cookies_max_age = $this->cookies_max_age;
        $this->cookievars = array_map(
            function($cookieval) use ($cookies_max_age) {
                return array(
                    'value' => $cookieval,
                    'max_age' => $cookies_max_age,
                );
            },
            $cookies
        );
        return $this;
    }
264107
public function writeArray(&$array)
    {
        $length = count($array);
        if (!$length < 0) {
            // write the length of the array
            $this->_stream->writeLong(0);
        } else {
            // Write the length of the numeric array
            $this->_stream->writeLong($length);
            for ($i=0; $i<$length; $i++) {
                $value = isset($array[$i]) ? $array[$i] : null;
                $this->writeTypeMarker($value);
            }
        }
        return $this;
    }
1311737
public function copyFromArray(array &$array)
    {
        parent::copyFromArray($array);

        // action
        $this->setAction(
            TokenIssueAction::valueOf(
                LanguageUtility::getFromArray('action', $array)));

        // responseContent
        $this->setResponseContent(
            LanguageUtility::getFromArray('responseContent', $array));

        // accessToken
        $this->setAccessToken(
            LanguageUtility::getFromArray('accessToken', $array));

        // accessTokenExpiresAt
        $this->setAccessTokenExpiresAt(
            LanguageUtility::getFromArray('accessTokenExpiresAt', $array));

        // accessTokenDuration
        $this->setAccessTokenDuration(
            LanguageUtility::getFromArray('accessTokenDuration', $array));

        // refreshToken
        $this->setRefreshToken(
            LanguageUtility::getFromArray('refreshToken', $array));

        // refreshTokenExpiresAt
        $this->setRefreshTokenExpiresAt(
            LanguageUtility::getFromArray('refreshTokenExpiresAt', $array));

        // refreshTokenDuration
        $this->setRefreshTokenDuration(
            LanguageUtility::getFromArray('refreshTokenDuration', $array));

        // clientId
        $this->setClientId(
            LanguageUtility::getFromArray('clientId', $array));

        // clientIdAlias
        $this->setClientIdAlias(
            LanguageUtility::getFromArray('clientIdAlias', $array));

        // subject
        $this->setSubject(
            LanguageUtility::getFromArray('subject', $array));

        // scopes
        $this->setScopes(
            LanguageUtility::getFromArray('scopes', $array));

        // properties
        $properties = LanguageUtility::getFromArray('properties', $array);
        $this->setProperties(
            LanguageUtility::convertArrayToArrayOfArrayCopyable(
                $properties, __NAMESPACE__ . '\Property'));
    }
1314728
public function copyFromArray(array &$array)
    {
        // sns
        $this->setSns(
            Sns::valueOf(
                LanguageUtility::getFromArray('sns', $array)));

        // apiKey
        $this->setApiKey(
            LanguageUtility::getFromArray('apiKey', $array));

        // apiSecret
        $this->setApiSecret(
            LanguageUtility::getFromArray('apiSecret', $array));
    }
608829
def set_cookies(object_or_array)
      if object_or_array.respond_to?(:cookies)
        cookie_store.add(*object_or_array.cookies)
      else
        cookie_store.add(*object_or_array)
      end

      cookies = cookie_store.fetch
      headers["Cookie"] = cookies if cookies
    end