ampproject / ampproject/amphtml

Make it possible to set cookies client-side

Open
#25,670 24 comments 9 reactions 0 assignees View on GitHub
Stale Type: Feature Request WG: runtime
Dominant language
JavaScript
Stars
14.9k
Forks
4.1k
PR merge metrics
No merged PRs in 30d

Description

We hear this request often from more sophisticated and experienced AMP site creators - to allow reading and setting of cookies from ``, ``, and/or ``.

A common workaround is to set cookies server-side, which sometimes makes it necessary to create an API to set cookies. We want AMP to make things easier for developers, and unfortunately this server-side workaround makes the experience harder for developers and users alike.

Of course, being able to set cookies from `` would be nice too, and might cover these use cases. But it would be great to add this to older interactive components as, of course, they're far more widely adopted at the moment.

One possible format:

`on="tap:AMP.setCookie({currency: 'USD'})"`

/cc @mattwomple , @SimonHogstromRonbol, @nainar, @choumx

Contributor guide

Open the contributing guide

Research direction

Start by reviewing the client-side entry points named in the issue: amp-bind, amp-list, amp-analytics, and amp-script. The issue does not identify files or tests, so first define the supported cookie behavior, API shape, and security constraints before determining what implementation and coverage would count as done.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript
Domain
frontend
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.