public function set($name, $value, $deleteCookie = false)
    {
        $attributeValueList = [];

        if ($this->cookieOptions['Secure']) {
            $attributeValueList[] = 'Secure';
        }
        if ($this->cookieOptions['HttpOnly']) {
            $attributeValueList[] = 'HttpOnly';
        }

        if (null !== $this->cookieOptions['Path']) {
            $attributeValueList[] = \sprintf('Path=%s', $this->cookieOptions['Path']);
        }
        if (null !== $this->cookieOptions['Domain']) {
            $attributeValueList[] = \sprintf('Domain=%s', $this->cookieOptions['Domain']);
        }

        if (null !== $this->cookieOptions['Max-Age'] && !$deleteCookie) {
            $attributeValueList[] = \sprintf('Max-Age=%d', $this->cookieOptions['Max-Age']);
        }

        if ($deleteCookie) {
            // Max-Age=0 is a special value indicating to the browser that the
            // cookie has to be deleted...
            $attributeValueList[] = 'Max-Age=0';
        }

        if (null !== $this->cookieOptions['SameSite']) {
            $attributeValueList[] = \sprintf('SameSite=%s', $this->cookieOptions['SameSite']);
        }

        $this->header->set(
            \sprintf(
                'Set-Cookie: %s=%s; %s',
                $name,
                $value,
                \implode('; ', $attributeValueList)
            ),
            false // do not replace
        );
    }
public function set($name, $value, $deleteCookie = false)
    {
        $attributeValueList = [];

        if ($this->cookieOptions['Secure']) {
            $attributeValueList[] = 'Secure';
        }
        if ($this->cookieOptions['HttpOnly']) {
            $attributeValueList[] = 'HttpOnly';
        }

        if (null !== $this->cookieOptions['Path']) {
            $attributeValueList[] = \sprintf('Path=%s', $this->cookieOptions['Path']);
        }
        if (null !== $this->cookieOptions['Domain']) {
            $attributeValueList[] = \sprintf('Domain=%s', $this->cookieOptions['Domain']);
        }

        if (null !== $this->cookieOptions['Max-Age'] && !$deleteCookie) {
            $attributeValueList[] = \sprintf('Max-Age=%d', $this->cookieOptions['Max-Age']);
        }

        if ($deleteCookie) {
            // Max-Age=0 is a special value indicating to the browser that the
            // cookie has to be deleted...
            $attributeValueList[] = 'Max-Age=0';
        }

        if (null !== $this->cookieOptions['SameSite']) {
            $attributeValueList[] = \sprintf('SameSite=%s', $this->cookieOptions['SameSite']);
        }

        $this->header->set(
            \sprintf(
                'Set-Cookie: %s=%s; %s',
                $name,
                $value,
                \implode('; ', $attributeValueList)
            ),
            false // do not replace
        );
    }
public function set ( $ name , $ value , $ deleteCookie = false ) { $ attributeValueList = [ ] ; if ( $ this -> cookieOptions [ 'Secure' ] ) { $ attributeValueList [ ] = 'Secure' ; } if ( $ this -> cookieOptions [ 'HttpOnly' ] ) { $ attributeValueList [ ] = 'HttpOnly' ; } if ( null !== $ this -> cookieOptions [ 'Path' ] ) { $ attributeValueList [ ] = \ sprintf ( 'Path=%s' , $ this -> cookieOptions [ 'Path' ] ) ; } if ( null !== $ this -> cookieOptions [ 'Domain' ] ) { $ attributeValueList [ ] = \ sprintf ( 'Domain=%s' , $ this -> cookieOptions [ 'Domain' ] ) ; } if ( null !== $ this -> cookieOptions [ 'Max-Age' ] && ! $ deleteCookie ) { $ attributeValueList [ ] = \ sprintf ( 'Max-Age=%d' , $ this -> cookieOptions [ 'Max-Age' ] ) ; } if ( $ deleteCookie ) { // Max-Age=0 is a special value indicating to the browser that the // cookie has to be deleted... $ attributeValueList [ ] = 'Max-Age=0' ; } if ( null !== $ this -> cookieOptions [ 'SameSite' ] ) { $ attributeValueList [ ] = \ sprintf ( 'SameSite=%s' , $ this -> cookieOptions [ 'SameSite' ] ) ; } $ this -> header -> set ( \ sprintf ( 'Set-Cookie: %s=%s; %s' , $ name , $ value , \ implode ( '; ' , $ attributeValueList ) ) , false // do not replace ) ; }
Set a cookie value.

@param string $name         the cookie name
@param string $value        the cookie value
@param bool   $deleteCookie tell browser to delete the cookie

@return void
Set a cookie value .