public function setCookie(
		$name,
		$value = '',
		$expire = '',
		$domain = '',
		$path = '/',
		$prefix = '',
		$secure = false,
		$httponly = false
	)
	{
		if (is_array($name))
		{
			// always leave 'name' in last place, as the loop will break otherwise, due to $$item
			foreach (['value', 'expire', 'domain', 'path', 'prefix', 'secure', 'httponly', 'name'] as $item)
			{
				if (isset($name[$item]))
				{
					$$item = $name[$item];
				}
			}
		}

		if ($prefix === '' && $this->cookiePrefix !== '')
		{
			$prefix = $this->cookiePrefix;
		}

		if ($domain === '' && $this->cookieDomain !== '')
		{
			$domain = $this->cookieDomain;
		}

		if ($path === '/' && $this->cookiePath !== '/')
		{
			$path = $this->cookiePath;
		}

		if ($secure === false && $this->cookieSecure === true)
		{
			$secure = $this->cookieSecure;
		}

		if ($httponly === false && $this->cookieHTTPOnly !== false)
		{
			$httponly = $this->cookieHTTPOnly;
		}

		if (! is_numeric($expire))
		{
			$expire = time() - 86500;
		}
		else
		{
			$expire = ($expire > 0) ? time() + $expire : 0;
		}

		$this->cookies[] = [
			'name'     => $prefix . $name,
			'value'    => $value,
			'expires'  => $expire,
			'path'     => $path,
			'domain'   => $domain,
			'secure'   => $secure,
			'httponly' => $httponly,
		];

		return $this;
	}
public function setCookie(
		$name,
		$value = '',
		$expire = '',
		$domain = '',
		$path = '/',
		$prefix = '',
		$secure = false,
		$httponly = false
	)
	{
		if (is_array($name))
		{
			// always leave 'name' in last place, as the loop will break otherwise, due to $$item
			foreach (['value', 'expire', 'domain', 'path', 'prefix', 'secure', 'httponly', 'name'] as $item)
			{
				if (isset($name[$item]))
				{
					$$item = $name[$item];
				}
			}
		}

		if ($prefix === '' && $this->cookiePrefix !== '')
		{
			$prefix = $this->cookiePrefix;
		}

		if ($domain === '' && $this->cookieDomain !== '')
		{
			$domain = $this->cookieDomain;
		}

		if ($path === '/' && $this->cookiePath !== '/')
		{
			$path = $this->cookiePath;
		}

		if ($secure === false && $this->cookieSecure === true)
		{
			$secure = $this->cookieSecure;
		}

		if ($httponly === false && $this->cookieHTTPOnly !== false)
		{
			$httponly = $this->cookieHTTPOnly;
		}

		if (! is_numeric($expire))
		{
			$expire = time() - 86500;
		}
		else
		{
			$expire = ($expire > 0) ? time() + $expire : 0;
		}

		$this->cookies[] = [
			'name'     => $prefix . $name,
			'value'    => $value,
			'expires'  => $expire,
			'path'     => $path,
			'domain'   => $domain,
			'secure'   => $secure,
			'httponly' => $httponly,
		];

		return $this;
	}
public function setCookie ( $ name , $ value = '' , $ expire = '' , $ domain = '' , $ path = '/' , $ prefix = '' , $ secure = false , $ httponly = false ) { if ( is_array ( $ name ) ) { // always leave 'name' in last place, as the loop will break otherwise, due to $$item foreach ( [ 'value' , 'expire' , 'domain' , 'path' , 'prefix' , 'secure' , 'httponly' , 'name' ] as $ item ) { if ( isset ( $ name [ $ item ] ) ) { $ $ item = $ name [ $ item ] ; } } } if ( $ prefix === '' && $ this -> cookiePrefix !== '' ) { $ prefix = $ this -> cookiePrefix ; } if ( $ domain === '' && $ this -> cookieDomain !== '' ) { $ domain = $ this -> cookieDomain ; } if ( $ path === '/' && $ this -> cookiePath !== '/' ) { $ path = $ this -> cookiePath ; } if ( $ secure === false && $ this -> cookieSecure === true ) { $ secure = $ this -> cookieSecure ; } if ( $ httponly === false && $ this -> cookieHTTPOnly !== false ) { $ httponly = $ this -> cookieHTTPOnly ; } if ( ! is_numeric ( $ expire ) ) { $ expire = time ( ) - 86500 ; } else { $ expire = ( $ expire > 0 ) ? time ( ) + $ expire : 0 ; } $ this -> cookies [ ] = [ 'name' => $ prefix . $ name , 'value' => $ value , 'expires' => $ expire , 'path' => $ path , 'domain' => $ domain , 'secure' => $ secure , 'httponly' => $ httponly , ] ; return $ this ; }
Set a cookie

Accepts an arbitrary number of binds (up to 7) or an associative
array in the first parameter containing all the values.

@param string|array  $name     Cookie name or array containing binds
@param string        $value    Cookie value
@param string        $expire   Cookie expiration time in seconds
@param string        $domain   Cookie domain (e.g.: '.yourdomain.com')
@param string        $path     Cookie path (default: '/')
@param string        $prefix   Cookie name prefix
@param boolean|false $secure   Whether to only transfer cookies via SSL
@param boolean|false $httponly Whether only make the cookie accessible via HTTP (no javascript)

@return $this
Set a cookie