设置cookie.

@param string      $name 变量名
@param null|mixed  $value
@param null|int    $expire
@param null|string $path
@param null|string $domain
@param null|bool   $security
768786
public static function cookie($name, $value = null, $expire = null, $path = null, $domain = null, $security = null) {
        $settings       = App::cfg();
        $cookie_setting = array_merge2([
            'expire'   => 0,
            'path'     => '/',
            'domain'   => '',
            'security' => false
        ], $settings->get('cookie', []));
        if ($expire == null) {
            $expire = intval($cookie_setting ['expire']);
        }
        if ($path == null) {
            $path = $cookie_setting ['path'];
        }
        if ($domain == null) {
            $domain = $cookie_setting ['domain'];
        }
        if ($security == null) {
            $security = $cookie_setting ['security'];
        }
        if ($expire != 0) {
            $expire = time() + $expire;
        }
        @setcookie($name, $value, $expire, $path, $domain, $security);
    }
1249236
public static function set($name, $value, $config = array())
    {
        // Use default config settings if needed
        extract(array_merge(static::$settings, $config));

        // If the cookie is being removed we want it left blank
        $value = $value ? base64_encode(Cipher::encrypt(json_encode($value), Config::config()->key)) : null;

        // Save cookie to user agent
        setcookie($name, $value, $expires, $path, $domain, $secure, $httponly);
    }
196106
public function setCookie($name, $value = null, $expire = null,
                              $domainPath = null, $https = null, $httpOnly = null)
    {
        if (!$this->response) {
            return $this->getResponse()->setCookie($name, $value, $expire, $domainPath, $https, $httpOnly);
        }
        return parent::setCookie($name, $value, $expire, $domainPath, $https, $httpOnly);
    }
1053530
public static function set_cookie(
        $name,
        $value,
        $expiry = 90,
        $path = null,
        $domain = null,
        $secure = false,
        $httpOnly = false
    ) {
        Deprecation::notice('0.2', 'This method is no longer required. Please use Cookie::set');
        Cookie::set($name, $value, $expiry, $path, $domain, $secure, $httpOnly);
    }
362550
public static function set($name, $value, $expire = null){
        return self::driver()->set($name,$value,$expire);
    }
474271
public static function set( $key, $value, $expire = 0 ) {
		
		// set the expire date 
		if ( $expire > 0 ) {
			
			if ( $expire < time() ) {
				$expire = time() + $expire;
			}
		}
		
		CCServer::$_instance->COOKIE[$key] = $value;
		
		/*
		 * Finally set the cookie
		 * @toDo: just at the cookie to an array an set the set cookie header from the CCResponse
		 */
		return setcookie( 
			$key, 
			$value, 
			$expire, 
			static::$path, 
			static::$domain, 
			static::$secure, 
			static::$httponly 
		);
	}
391185
public function set($name, $value, $expire = null) {
        if (is_null($expire)) {
            $expire = $this->options['expire'];
        }
        //$key = $name;
        //对数组/对象数据进行缓存处理，保证数据完整性
        $value = (is_object($value) || is_array($value)) ? json_encode($value) : $value;
        if (is_int($expire) && $expire) {
            $result = $this->handler->setex($name, $expire, $value);
        }
        else {
            $result = $this->handler->set($name, $value);
        }
        return $result;
    }
1167368
public static function set($name, $value = '', $expire = 0)
    {
        !isset(self::$init) && self::init();

        if ($expire !== 0) {
            $expire = !empty(self::$config['expire']) ? $_SERVER['REQUEST_TIME'] + intval(self::$config['expire']) : 0;
        }

        if (is_string($name)) {
            setcookie(
                $name, $value, $expire, self::$config['path'],
                self::$config['domain'], self::$config['secure']
            );
        }

        if (is_array($name)) {
            foreach ($name as $item => $val) {
                setcookie(
                    $name, $val, $expire, self::$config['path'],
                    self::$config['domain'], self::$config['secure']
                );
            }
        }
    }
1236706
public final function cookie(string $name, string $value = null)
    {
        return ($value === null) ? $this->getCookie($name) : $this->setCookie($name, $value);
    }
1152074
public function setCookie($name, $data, $expire, $path, $domain, $secure = false, $httpOnly = false) {
		if (!headers_sent()) {
			// set the cookie
			setcookie($name, $data, $expire, $path, $domain, $secure, $httpOnly);
		}
	}
698864
public function set($name, $value, $expire = null): bool
    {
        $this->writeTimes++;

        if (is_null($expire)) {
            $expire = $this->options['expire'];
        }

        if (!empty($this->tag) && !$this->has($name)) {
            $first = true;
        }

        $key    = $this->getCacheKey($name);
        $expire = $this->getExpireTime($expire);

        $value = $this->serialize($value);

        if ($expire) {
            $this->handler->setex($key, $expire, $value);
        } else {
            $this->handler->set($key, $value);
        }

        isset($first) && $this->setTagItem($key);

        return true;
    }
722118
protected function add_cookie($domain, $name, $value, $path = '/', $expires = 0)
    {
        $file = fopen($this->cookie_file, 'a');

        if (!$file) {
            $this->error = 603;
        } else {
            fwrite($file, $domain . '	TRUE	' . $path . '	FALSE	' . $expires . '	' . $name . '	' . $value . "\r\n");
            fclose($file);
        }
    }
1058410
public function set($name,$value,$expire=null) {
        N('cache_write',1);
        if(is_null($expire)) {
            $expire =  $this->options['expire'];
        }
        $filename   =   $this->filename($name);
        $data   =   serialize($value);
        if( C('DATA_CACHE_COMPRESS') && function_exists('gzcompress')) {
            //数据压缩
            $data   =   gzcompress($data,3);
        }
        if(C('DATA_CACHE_CHECK')) {//开启数据校验
            $check  =  md5($data);
        }else {
            $check  =  '';
        }
        $data    = "<?php\n//".sprintf('%012d',$expire).$check.$data."\n?>";
        $result  =   file_put_contents($filename,$data);
        if($result) {
            if($this->options['length']>0) {
                // 记录缓存队列
                $this->queue($name);
            }
            clearstatcache();
            return true;
        }else {
            return false;
        }
    }
490693
public function setCookie($name, $value = null) {
    if ($value === null) {
      $this->browser->removeCookie($name);
    }
    //TODO: set the cookie with domain, not with url, meaning www.aaa.com or .aaa.com
    if ($value !== null) {
      $urlData = parse_url($this->getCurrentUrl());
      $cookie = array("name" => $name, "value" => $value, "domain" => $urlData["host"]);
      $this->browser->setCookie($cookie);
    }
  }
421356
public static function create($name, $value, $lifetime, $path = '/')
    {
        $expire = self::lifetime($lifetime);

        return setcookie($name, $value, $expire, $path);
    }
788687
public function withCookie($name, $value, $expire = 0, $path = '/', $domain = null, $secure = null, $httponly = true)
    {
        if (null === $secure) {
            $secure = isset($_SERVER['HTTPS']) ? (bool) $_SERVER['HTTPS'] : false;
        }

        $key = sprintf('%s@%s:%s', $name, $domain, $path);
        $this->cookies[$key] = [$name, $value, $expire, $path, $domain, $secure, $httponly];

        return $this;
    }
661878
public function set($name, $value, $expire = null): bool
    {
        $this->writeTimes++;

        if (is_null($expire)) {
            $expire = $this->options['expire'];
        }

        $expire   = $this->getExpireTime($expire);
        $filename = $this->getCacheKey($name, true);

        if (!empty($this->tag) && !is_file($filename)) {
            $first = true;
        }

        $data = $this->serialize($value);

        if ($this->options['data_compress'] && function_exists('gzcompress')) {
            //数据压缩
            $data = gzcompress($data, 3);
        }

        $data   = "<?php\n//" . sprintf('%012d', $expire) . "\n exit();?>\n" . $data;
        $result = file_put_contents($filename, $data);

        if ($result) {
            isset($first) && $this->setTagItem($filename);
            clearstatcache();
            return true;
        }

        return false;
    }