setCookie() * @see \CodeIgniter\HTTP\Response::setCookie() * @return void */ function set_cookie ( $name, string $value = '', string $expire = '', string $domain = '', string $path = '/', string $prefix = '', bool $secure = false, bool $httpOnly = false ) { (\Config\Services::response(new \Config\App()))->setcookie ( $name, $value, $expire, $domain, $path, $secure, $httpOnly ); } } //-------------------------------------------------------------------- if ( ! function_exists('get_cookie')) { /** * Fetch an item from the COOKIE array * * @param mixed $index * @param bool $xssClean * @see (\Config\Services::request())->getCookie() * @see \CodeIgniter\HTTP\IncomingRequest::getCookie() * @return mixed */ function get_cookie($index, bool $xssClean = false) { $app = new \Config\App(); $prefix = $app->cookiePrefix; $index = $prefix . $index; $request = \Config\Services::request($app); $filter = true === $xssClean ? FILTER_SANITIZE_STRING : null; $cookie = $request->getCookie($index, $filter); return $cookie; } } //-------------------------------------------------------------------- if ( ! function_exists('delete_cookie')) { /** * Delete a COOKIE * * @param mixed $name * @param string $domain the cookie domain. Usually: .yourdomain.com * @param string $path the cookie path * @param string $prefix the cookie prefix * @see \CodeIgniter\HTTP\Response::setcookie() * @return void */ function delete_cookie ( $name, string $domain = '', string $path = '/', string $prefix = '' ) { set_cookie($name, '', '', $domain, $path, $prefix); } }