设置cookie
@param [type] $name     [名字 ]
@param [type] $value    [值]
@param [type] $expires  [过期时间]
@param [type] $path     [路径]
@param [type] $domain   [域名]
@param [type] $secure   [https?]
@param [type] $httpOnly [httponly]
335279
public function setCookie(
        $name,
        $value,
        $expires = null,
        $path = null,
        $domain = null,
        $secure = null,
        $httpOnly = null
    ) {
        $expires  = is_null($expires) ? $this->vitex->getConfig('cookies.lifetime') : $expires;
        $path     = is_null($path) ? $this->vitex->getConfig('cookies.path') : $path;
        $domain   = is_null($domain) ? $this->vitex->getConfig('cookies.domain') : $domain;
        $secure   = is_null($secure) ? $this->vitex->getConfig('cookies.secure') : $secure;
        $httpOnly = is_null($httpOnly) ? $this->vitex->getConfig('cookies.httponly') : $httpOnly;
        if (!is_numeric($expires)) {
            $expires = strtotime($expires);
        }
        $secret_key = $this->vitex->getConfig('cookies.secret_key');
        $encrypt    = $this->vitex->getConfig('cookies.encrypt');
        if ($encrypt) {
            $value = Utils::encrypt($value, $secret_key);
        }
        setcookie($name, $value, $expires, $path, $domain, $secure, $httpOnly);
    }
842979
public function setSecure(
        $name = '',
        $value = '',
        $expire = 0,
        $path = '/',
        $domain = '',
        $secure = false,
        $httpOnly = false
    ) {
        if (empty($value)) {
            Craft::$app->response->cookies->remove($name);
        } else {
            $domain = empty($domain) ? Craft::$app->getConfig()->getGeneral()->defaultCookieDomain : $domain;
            $expire = (int)$expire;
            $cookie = new Cookie(['name' => $name, 'value' => '']);

            try {
                $cookie->value = Craft::$app->security->hashData(base64_encode(serialize($value)));
            } catch (InvalidConfigException $e) {
                Craft::error(
                    'Error setting secure cookie: '.$e->getMessage(),
                    __METHOD__
                );

                return;
            } catch (Exception $e) {
                Craft::error(
                    'Error setting secure cookie: '.$e->getMessage(),
                    __METHOD__
                );

                return;
            }
            $cookie->expire = $expire;
            $cookie->path = $path;
            $cookie->domain = $domain;
            $cookie->secure = $secure;
            $cookie->httpOnly = $httpOnly;

            Craft::$app->response->cookies->add($cookie);
        }
    }
828191
public function set($name, $value, $expire = 604800, $path = '/', $domain = '')
    {
        if (empty($domain)) {
            // $domain = '.' . $_SERVER['HTTP_HOST'];
            setcookie($name, $value, $expire + time(), $path);
        } else {
            setcookie($name, $value, $expire + time(), $path, $domain);
        }

        // Make it come into effect immediately.
        $_COOKIE[$name] = $value;
    }
241402
public function make($name, $value, $minutes = 0, $path = null, $domain = null, $secure = null, $httpOnly = true)
    {
        $path = is_null($path) ? $this->path : $path;
        $domain = is_null($domain) ? $this->domain : $domain;
        $secure = is_null($secure) ? $this->secure : $secure;

        $time = ($minutes == 0) ? 0 : time() + ($minutes * 60);

        return new Cookie($name, $value, $time, $path, $domain, $secure, $httpOnly);
    }
64318
public function set_cookie($name, $value = null)
	{
		is_null($value)
			? $this->connection()->__setCookie($name)
			: $this->connection()->__setCookie($name, $value);
	}
48092
public static function create(string $name, $value, int $expire = 1209600)
    {
        $cookieText = 'Set-Cookie: '.$name.'='.$value;
        
        $expireTime = new \DateTime;
        $expireTime->modify('+ '.$expire.' second');
        $cookieText .= '; Expires='.$expireTime->format('D, d M Y H:i:s e');
        
        $cookieText .= '; Path='.self::$path;
        $cookieText .= '; Domain='.self::$domain;
        
        if (self::$httpOnly === true) {
            $cookieText .= '; HttpOnly';
        }
        
        if (self::$secure === true) {
            $cookieText .= '; Secure';
        }
        
        if (!empty(self::$sameSite)) {
            $cookieText .= '; Samesite='.self::$sameSite;
        }
        
        header($cookieText);
    }
589816
public void setCookie(String name, String value, String path, Date expirationDate, boolean secure, boolean httpOnly) {
        if (remote == null)
            throw new IllegalStateException("Cannot setCookie since remote == null");
        if (path == null || path.length() == 0)
            path = remote.getPath();
        Cookie.Builder builder = new Cookie.Builder();
        builder.name(name).value(value).domain(remote.getHost()).path(path);
        if (expirationDate != null)
            builder.expiresAt(expirationDate.getTime());
        List<Cookie> cookies = Collections.singletonList(builder.build());
        this.clientFactory.addCookies(cookies);
    }
827788
public function cookiesUpdate(
        $name,
        $value,
        $expires = null,
        $path = '/',
        $domain = null,
        $secure = false,
        $httpOnly = false
    )
    {
        return new Context\Cookies\Update(
            $name,
            $value,
            $expires,
            $path,
            $domain,
            $secure,
            $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);
    }
1057558
public function set(
        $name = '',
        $value = '',
        $expire = 0,
        $path = '/',
        $domain = '',
        $secure = false,
        $httpOnly = false
    ) {
        if (empty($value)) {
            Craft::$app->response->cookies->remove($name);
        } else {
            $domain = empty($domain) ? Craft::$app->getConfig()->getGeneral()->defaultCookieDomain : $domain;
            $expire = (int)$expire;
            setcookie($name, $value, $expire, $path, $domain, $secure, $httpOnly);
            $_COOKIE[$name] = $value;
        }
    }
31310
public function cookie($name, $value, $expires = 0, $path = '', $domain = '', $secure = false, $httpOnly = false)
    {
        $cookie = new Cookie(
            $name,
            $value,
            $expires
        );

        return $cookie
            ->setPath($path)
            ->setDomain($domain)
            ->setIsSecure($secure)
            ->setIsHttpOnly($httpOnly)
            ->commit();
    }
196002
public function set($name, $value, $expire) {
        if (is_null($expire)) {
            $expire = $this->options[ 'expire' ];
        }
        $filename = $this->getCacheFile($name);

        $data = serialize($value);
        if ($this->options[ 'data_compress' ] && function_exists('gzcompress')) {
            //数据压缩
            $data = gzcompress($data, 3);
        }
        $data = "<?php\n//" . sprintf('%012d', $expire) . $data . "\n?>";
        $result = file_put_contents($filename, $data);
        if ($result) {
            clearstatcache();
            return true;
        } else {
            return false;
        }
    }
64977
public function setCookie($name, $value)
    {
        if (strlen($name) == 0) {
            return false;
        }
        $this->cookies[] = array('name' => $name, 'value' => $value);
        return true;
    }
238444
public function setSecret($name, $value, $expire = 604800, $path = '/', $domain = '')
    {
        $value = \ePHP\Hash\Encrypt::encryptG($value, md5($_SERVER['HTTP_HOST'].APP_PATH.SERVER_MODE));
        $this->set($name, $value, $expire, $path, $domain);
    }
1309702
public static function set(
        $name,
        $value,
        $expiry = 90,
        $path = null,
        $domain = null,
        $secure = false,
        $httpOnly = true
    ) {
        return self::get_inst()->set($name, $value, $expiry, $path, $domain, $secure, $httpOnly);
    }
660432
public function set($name, $value, $expire = 0)
    {
        $cookie_name = $this->getName($name);
        $cookie_expire = time() + ($expire ? $expire : $this->_expire);
        $cookie_value = $this->pack($value, $cookie_expire);
        $cookie_value = $this->authcode($cookie_value, 'ENCODE', $this->_securekey);

        if ($cookie_name && $cookie_value && $cookie_expire) {
            setcookie($cookie_name, $cookie_value, $cookie_expire, '/');
        }

    }
866549
public function set($name, $value,$expire=null) {
        $data   =  serialize($value);
        $name   =  $this->options['prefix'].addslashes($name);
        N('cache_write',1);
        if( C('DATA_CACHE_COMPRESS') && function_exists('gzcompress')) {
            //数据压缩
            $data   =   gzcompress($data,3);
        }
        if(C('DATA_CACHE_CHECK')) {//开启数据校验
            $crc  =  md5($data);
        }else {
            $crc  =  '';
        }
        if(is_null($expire)) {
            $expire  =  $this->options['expire'];
        }
        $expire	    =   ($expire==0)?0: (time()+$expire) ;//缓存有效期为0表示永久缓存
        $result     =   $this->handler->query('select `cachekey` from `'.$this->options['table'].'` where `cachekey`=\''.$name.'\' limit 0,1');
        if(!empty($result) ) {
        	//更新记录
            $result  =  $this->handler->execute('UPDATE '.$this->options['table'].' SET data=\''.$data.'\' ,datacrc=\''.$crc.'\',expire='.$expire.' WHERE `cachekey`=\''.$name.'\'');
        }else {
        	//新增记录
             $result  =  $this->handler->execute('INSERT INTO '.$this->options['table'].' (`cachekey`,`data`,`datacrc`,`expire`) VALUES (\''.$name.'\',\''.$data.'\',\''.$crc.'\','.$expire.')');
        }
        if($result) {
            if($this->options['length']>0) {
                // 记录缓存队列
                $this->queue($name);
            }
            return true;
        }else {
            return false;
        }
    }