Cookie · Mecha CMS

Persistent storage using cookies.

$cookie::set()

Author: Taufik Nurrohman · 213 Views

Tweet

Set a cookie.

Cookie::set($key, $value = "", $config = [
    'expire' => 1,
    'path' => '/',
    'domain' => "",
    'secure' => false,
    'http_only' => false
] | $expire);

Example:

Cookie::set('my_cookie', 'the value', 1); // expired in a day

Set a cookie with advance configuration data:

Cookie::set('my_cookie', 'the value', [
    'expire' => 1,
    'path' => '/',
    'domain' => "",
    'secure' => false,
    'http_only' => true // not available in `document.cookie`
]);