public function set(string $name, $value, $expire = 0, $path = null, $domain = null, bool $secure = false, bool $httponly = true)
    {
        $name = preg_match('/[=,; \t\r\n\013\014]/', $name) ? rand(1, 25) : $name;
        if ($expire instanceof \DateTime) {
            $expire = $expire->format('U');
        } elseif (preg_match('~\D~', $expire)) {
            $expire = strtotime($expire);
        } else {
            $expire = $expire;
            if (false === $expire) {
                throw new \InvalidArgumentException('The cookie expiration time is not valid.', 500);
            }
        }
        [$path, $domain, $secure] = $this->getPathAndDomain($path, $domain, $secure);

        return setcookie($name, $value, $expire, $path, $domain, $secure, $httponly);
    }
public function set(string $name, $value, $expire = 0, $path = null, $domain = null, bool $secure = false, bool $httponly = true)
    {
        $name = preg_match('/[=,; \t\r\n\013\014]/', $name) ? rand(1, 25) : $name;
        if ($expire instanceof \DateTime) {
            $expire = $expire->format('U');
        } elseif (preg_match('~\D~', $expire)) {
            $expire = strtotime($expire);
        } else {
            $expire = $expire;
            if (false === $expire) {
                throw new \InvalidArgumentException('The cookie expiration time is not valid.', 500);
            }
        }
        [$path, $domain, $secure] = $this->getPathAndDomain($path, $domain, $secure);

        return setcookie($name, $value, $expire, $path, $domain, $secure, $httponly);
    }
public function set ( string $ name , $ value , $ expire = 0 , $ path = null , $ domain = null , bool $ secure = false , bool $ httponly = true ) { $ name = preg_match ( '/[=,; \t\r\n\013\014]/' , $ name ) ? rand ( 1 , 25 ) : $ name ; if ( $ expire instanceof \ DateTime ) { $ expire = $ expire -> format ( 'U' ) ; } elseif ( preg_match ( '~\D~' , $ expire ) ) { $ expire = strtotime ( $ expire ) ; } else { $ expire = $ expire ; if ( false === $ expire ) { throw new \ InvalidArgumentException ( 'The cookie expiration time is not valid.' , 500 ) ; } } [ $ path , $ domain , $ secure ] = $ this -> getPathAndDomain ( $ path , $ domain , $ secure ) ; return setcookie ( $ name , $ value , $ expire , $ path , $ domain , $ secure , $ httponly ) ; }
Set the cookie value.

@param (string) $name     Name of cookie.
@param (mixed)  $value    Value to store in cookie.
@param (expire) $expire   TTL.
@param (string) $path     Path.
@param (domain) $domain   Domain.
@param (bool)   $secure   true | false.
@param (bool)   $httponly true | false.

@since 1.0.0

@return bool
Set the cookie value .