Webanizr Logo
Open / sluit menu
Module cookies

The cookies module handles cookies. It can create, read and remove cookies.

syntax (send)

webanizr.send('cookies', data, parameters, callback);

Data

The data that needs to be stored in the cookie.

Parameters

The cookies module accepts the following parameters:

name__cookie (required)

The name for the cookie.

type__action (optional)

This parameter tells the module what to do. The following options are available:

  • set: create a cookie with the given name.
  • remove: remove the cookie with the given name.

If this parameter is not set, the "set" option is performed.

days__expire (optional for the set option)

The number of days this cookie may exist. If no value is set, the cookie wil remain active for 30 days.

path__cookie (optional for the set option)

The path the cookie applies to. In no value is set, the root path (/) is used.

path__cookie (optional for the set option)

The path the cookie applies to. In no value is set, the root path (/) is used.

samesite__cookie (optional for the set option)

The SameSite flag. Can be valued Strict, Lax, or None. If no value is set, "Lax" is used.

httponly__cookie (optional for the set option)

The HttpOnly flag. Will be set if the value of this parameter is set, and has the value true

Secure

The Secure flag is automatically set depending on the protocol type of the document itself.

Callback

The callback function is called after setting / removing the cookie. The data is received by the send function is passed on.

syntax (collect)

webanizr.collect('cookies', parameters, callback);

parameters

The cookies module accepts the following parameters:

name__cookie (required)

The name of the cookie you want the content of.

callback

The callback is called with the content of the cookie as data. If the cookie is not found or expired, the value null is passed on.

demo

Creating, reading and removing cookies:

https://cdn.cpmodules.webanizr.com/demo/cookies/index.html