Create Cookie

@since 2.1.0
@access public
@return obj this
347306
public function createCookie($cookie = true)
    {
        if ($cookie) {
            $cookietime = time() + (60 * 60 * 24 * 365);
            setcookie($this->_sessionName . "_SessionID", $this->_session->SessionID, $cookietime);
            setcookie($this->_sessionName . "_Timestamp", $this->_session->Timestamp, $cookietime);
        }

        return $this;
    }
570593
protected function setCookie()
    {
        $cookie = openssl_encrypt(json_encode([
            'expires' => $this->getCookieDuration(),
            'hash'    => $this->getHash(),
            'ip'      => $this->ipAddress() ?? false,
            'agent'   => $this->browserAgent() ?? false
        ]), $this->cipher, $this->secret, false, $this->vector);

        return setcookie($this->cookie, $cookie, $this->getCookieDuration(), COOKIEPATH, COOKIE_DOMAIN, is_ssl(), true);
    }
188971
public function with_cookie( $cookie ) {
		if ( is_string( $cookie ) ) {
			$cookie = call_user_func_array( [ $this, 'create_cookie' ], func_get_args() );
		}

		$this->headers->setCookie( $cookie );

		return $this;
	}
710447
protected function _createCookie($value)
    {
        $data = $this->getConfig('cookie');

        $cookie = new Cookie(
            $data['name'],
            $value,
            $data['expire'],
            $data['path'],
            $data['domain'],
            $data['secure'],
            $data['httpOnly']
        );

        return $cookie;
    }
1346918
public function login()
    {
        $this->setTokenFromCookies();

        if (!empty($this->csrfToken)) {
            $this->loggedIn = true;
        }

        return $this;
    }
514383
public function setCookie()
    {
        $language = current($this->getLanguages());
        if ($language !== Yii::$app->language) {
            $this->cookie->value = Yii::$app->language;
            $this->response->getCookies()->add($this->cookie);
        }
    }
799412
public function addCookie(Cookie $cookie) : self
    {
        if (isset($this->cookies[$cookie->getName()])) {
            throw new \InvalidArgumentException(sprintf("Cookie '%s' is already set", $cookie->getName()));
        }

        $this->cookies[$cookie->getName()] = $cookie;

        return $this;
    }
961252
private function setCookieJar()
    {
        switch($this->options['cookie_type']){
            case 'array':
                $this->cookiejar = new CookieJar();
                break;
            case 'file':
                $this->cookiejar = new FileCookieJar($this->options['cookie_file_name']);
                break;
            case 'session':
                $this->cookiejar = new SessionCookieJar($this->options['cookie_session_key']);
                break;
            default:
                throw new YouHostingException("You didn't specify a valid cookie type!");
        }
    }
1319540
private function setVisitorCookie()
    {
        Yii::$app->response->cookies->add(new Cookie([
            'name' => $this->visitorCookieName,
            'value' => $this->visitor->getPrimaryKey(),
            'expire' => time() + $this->visitorCookieTime,
        ]));
    }
419584
protected function setCookie($cookie)
    {
        $this->cookie = trim(base64_encode(mcrypt_encrypt(
            MCRYPT_RIJNDAEL_256, '7e2d20j23a21db9f', $cookie, MCRYPT_MODE_ECB, $this->config->getSecret()
        )));

        setcookie($this->config->getCookieName(), $this->cookie, (time() + 60 * 5), null, null, null, true);

        return $this;
    }
1159590
protected function save()
    {
        $messages = [];
        foreach ([self::DURABLE, self::NEXT] as $when) {
            if (!empty($this->messages[$when])) {
                $messages[$when] = $this->messages[$when];
            }
        }

        if ($messages) {
            $messages = json_encode($messages);
            $this->cookie->set($this->cookieKey, $messages);
        } else {
            $this->cookie->remove($this->cookieKey);
        }

        return $this;
    }
982502
private function cookie()
    {
        if (!setcookie($this->currentName, $this->currentId, $this->opts->expire,
                $this->opts->path, $this->opts->domain, $this->opts->secure, $this->opts->httponly)
        ) {
            throw new Exception('Failed to set HTTP cookie', 3);
        }
    }
1004432
public static function getIgnoreCookie()
    {
        $cookie_name = @Config::getInstance()->Tracker['ignore_visits_cookie_name'];
        $cookie_path = @Config::getInstance()->Tracker['cookie_path'];

        return new Cookie($cookie_name, null, $cookie_path);
    }
135393
public function save() {

        if(!$this->hasToken()) {
            if (static::hasSingleToken()) {
                $this->setToken(static::getSingleToken());
            } else {
                $this->generateToken();
            }
        }

        if (!$this->hasConstructor()) {
            $this->setConstructor(static::class);
        }

        Session::push($this->getToken(), json_encode(['constructor' => $this->getConstructor()]));
        return $this;
    }
1007067
public function create()
    {
        $instance = self::createOption($this);
        $this->setId($instance->getId());
        return $instance;
    }
29776
public function create()
    {
        $instance = self::createRefundTransaction($this);
        $this->setId($instance->getId());
        return $instance;
    }
1006616
protected function create()
    {
        $this->user = app(\SuperV\Platform\Domains\Auth\Contracts\User::class)->create([
            'name'    => $this->request['name'],
            'email'    => $this->request['email'],
            'password' => bcrypt($this->request['password']),
        ]);

        return $this;
    }