Version: v0.8.1 - Beta.  We welcome contributors & feedback.

Cookie.set

Cookie.set($key, $value) -> null

Description

Set a cookie value for the given $key.

Cookie.set('language', 'fr')

// ... in a later request ...

Cookie.get('language')
//= 'fr'

Allowed Values

This method will only accept string values with alphanumeric characters a-zA-Z0-9, to support basic flags and IDs.

If you wish to persist data, it should be done securely, by storing it locally with Session instead.

Cookie Parameters

Cookies are set with the following flags:

Option Description
- httponly: true Cookies are only readable on the server, not via client-side JavaScript.
- secure: true Cookies are only sent over an HTTPS connection (except for local dev servers).
- samesite: Lax Cookies are sent when navigating to the site. See SameSite
- domain: '' Cookies are available to the local domain and subdomains
- path: / Cookies are available to all paths
- expires: 30 days Cookies expire in 30 days.

Work in Progress

This method is a work in progress. To have more control over the parameters, you can use Php.call('setcookie', {...}) with PHP's setcookie function.