consent/add-cookie adds a cookie to the declared list, so the preference centre names it under its consent category.
It needs the name a browser stores the cookie under, a category, and a description a visitor can actually understand.
At a glance
| Ability | consent/add-cookie |
| Toolset | CookieYes — toolset/cookieyes |
| Group | CookieYes › Declared Cookies |
| Requires | CookieYes, active on the site |
| Capability | manage_options |
| Safety | Writes data |
| Repeatable | Not idempotent — each call changes the row set, so re-running is not a no-op |
| Ships in | AcrossAI Abilities Manager 0.0.34 and later |
Declaring is not controlling
This changes what the banner says, not what the site does. Declaring _ga does not make Google Analytics load, and not declaring it does not stop it. The declaration is the disclosure, and the disclosure is what the banner is for.
Which means the failure mode runs the other way from what people expect: an inaccurate inventory makes the banner wrong, not the site. A cookie the site sets and does not declare is the gap that matters.
The banner a visitor receives is not assembled on the fly. It is cached HTML, built from the declared cookies, the consent categories and the settings, and rebuilt only when the consent plugin’s own save hooks fire. Write the consent tables any other way — through the database abilities, through another plugin — and the row reads back correctly while every visitor still sees the previous banner, with no error anywhere to say so.
So the write goes through the plugin’s own writer and then checks. The response reports whether the banner was refreshed, what it now contains per language, and whether a rebuild is still pending — the difference between stored and actually being served.
Description and duration each take either one string, applied to every language, or a map keyed by language code.
Input
| Name | Type | Required | What it is |
|---|---|---|---|
name | string | Yes | The cookie name as the browser stores it, for example _ga. |
category_id | integer | Yes | Consent category ID, from consent/list-categories. |
description | string | object | No | What the cookie does, in plain language. A plain string is applied to every language. A map keyed by language code sets them individually, and languages you leave out keep the text they already had. |
duration | string | object | No | How long it lasts, for example 1 year. A plain string is applied to every language. A map keyed by language code sets them individually, and languages you leave out keep the text they already had. |
domain | string | No | The domain that sets it. |
type | integer | No | The consent plugin’s own numeric cookie type. It publishes no meaning for the codes, so leave it unset unless you are copying an existing entry. |
url_pattern | string | No | Restrict the declaration to pages matching this pattern. |
What comes back
| Name | Type | What it is |
|---|---|---|
cookie | object | The declared cookie as stored. |
banner_refreshed | boolean | Whether the cached banner was rebuilt after the write. This is the field that says the change actually reached visitors. |
languages | array | The languages the banner is built for. |
rendered | object | The size of the built banner, per language. |
pending_rebuild | boolean | Whether the banner is still waiting to be rebuilt. True after a write means the change is stored but not yet being served. |
success | boolean | Whether the call completed. |
message | string | A one-line summary of what happened, suitable for showing a human. |
error_code | string | Present only on failure — a stable machine-readable reason, such as a missing field, a wrong field type or an unmet confirmation. |
Example
Ask your assistant:
Add the _ga cookie to our analytics category with a one-year duration.
It resolves to one call:
{
"ability": "consent/add-cookie",
"parameters": {
"name": "_ga",
"category_id": 3,
"description": "Distinguishes visitors so we can count them without identifying them.",
"duration": "1 year",
"domain": ".example.com"
}
}Worth knowing
- Write the description for a visitor, not for a developer. It is the text somebody reads before deciding.
- Not idempotent — declaring the same cookie twice lists it twice.
- Check
banner_refreshedin the response. A stored cookie that is not in the built banner is not being shown to anybody. - The category decides whether the cookie may load before consent. Put it in the right one.
Related abilities
- List Consent Categories — get the category ID first
- Update Declared Cookie — correct it afterwards
- Get Banner Status — confirm visitors are seeing it
Get the plugins:
AcrossAI Abilities Manager · AcrossAI MCP Manager
Browse the rest: Every ability, by category