PHP code example of webiik / cookie

1. Go to this page and download the library: Download webiik/cookie library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

webiik / cookie example snippets


$cookie = new \Webiik\Cookie\Cookie();
$cookie->setCookie('foo', 'bar');
if ($cookie->isCookie('foo')) {
    echo 'Cookie foo has value: ' . $cookie->getCookie('foo');
}
$cookie->delCookie('foo');

setDomain(string $domain): void

$cookie->setDomain('mydomain.tld');

setUri(string $uri): void

$cookie->setUri('/');

setSecure(bool $bool): void

$cookie->setSecure(true);

setHttpOnly(bool $bool): void

$cookie->setHttpOnly(true);

setCookie(string $name, string $value = '', int $expire = 0, string $uri = '', string $domain = '', bool $secure = false, bool $httponly = false): bool

$cookie->setCookie('foo', 'bar');

isCookie(string $name): bool

$cookie->isCookie('foo');

getCookie(string $name): string

$cookie->getCookie('foo');

delCookie($name): void

$cookie->delCookie('foo');

delCookies(): void

$cookie->delCookies();