Skip to content

Cookies

Cookies are small pieces of data that are stored on the user's browser. They are often used to store information about the user's session, such as unique identifiers, access tokens, and more.

They can be accessed via the c keyword in the Function Editor.

To create a cookie, click on the + button in the Cookies section of the Data Store. The following fields are available:

  • Name: The name of the cookie. This name must be unique and will be used to access the cookie via c.cookie_name.
  • Lifetime: Optionally, you can set an expiration time (in days) for the cookie. Any time Wized updates this cookie, the expiration time will be reset. If not set, the cookie be session-based and will expire when the user closes the browser.

Once created, Wized will automatically read the cookie value, if it is present in the user's browser.

Here's an example where we artificially set the cookie's value to 1234 to demonstrate how it works:

To update a cookie, you can either use the Set cookie action or use custom JavaScript.

WARNING

This is an advanced feature and should only be used if you know what you're doing.

All cookies can be updated using custom JavaScript instead of relying on the Set Cookie action. Any changes made to a cookie using JavaScript will be reflected in the app's state, triggering any dependent actions.

Similar to the Set Cookie action, when a cookie is updated using JavaScript Wized will automatically update the cookie in the user's browser.

Updating a cookie inside the Function Editor

To update a cookie inside the Function Editor, you can simply assign a new value to it:

js
(c, f, i, n, r, v, e, t) => {
  c.cookie_name = 'new value'; 
};
Updating a cookie via the JavaScript API

Cookies can also be updated via the JavaScript API:

js
Wized.data.c.cookie_name = 'new value';