Sets a cookie-variable.
This basically wraps the PHP function setcookie().
Syntax
setCookie(string $name, $value = "", string $expires = null, string $path = "", string $domain = "", bool $secure = true, bool $httponly = false): bool
- $name
The name of the cookie. - $value
The value of the cookie. This value is stored on the clients computer; do not store sensitive information. - $expires
The time the cookie expires. E.g. "2021-10-24 18:00".
Internally a PHP strtotime()-function is used to convert a given string.
If set to 0, or omitted, the cookie will expire at the end of the session (when the browser closes).
Return
Returns TRUE on success, else FALSE.
Example
Simply set a cookie variable "myVar":
{% do hublify.setCookie('myVar', 'Hello World!') %}