as

Settings
Sign out
Notifications
Alexa
Amazon Appstore
AWS
Documentation
Support
Contact Us
My Cases
Get Started
Design and Develop
Publish
Reference
Support

Vega Web App Cookie Manager

The cookie manager is useful for the following:

  • Adding a serialized cookie for a URL in a cookie store, which is attached to the cookie request header for the outgoing request.
  • Clearing all cookies from the cookie store.

A cookie object can have the following fields:

Field Type Required? (Y/N) Description
name string Y name means the name for the pair.
value string Y 'value' means the cookie value of the pair. A cookie is rejected if it has an empty value. It results in a no-op. If any other value is present, the value field will be preserved as an empty value.
path string N The value of the path attribute specifies the subset of URLs on the origin server for this cookie. If no specified path is given, the assumed path is the Uniform Resource Identifiers (URI) that sets the cookie.
domain string N The value of the domain attribute specifies the domain for which the cookie is valid. If no specified domain is given, the domain becomes inaccessible to its subdomains.
version string N Identifies the version of the state management specification for the cookie. The default value is an empty string.
expires string N Indicates the maximum lifetime of the cookie as an HTTP-date timestamp. Expected as an ISO8601 string. If no expiration string is given, the cookie is treated as a session cookie, which persists until the user closes their WebView session.
secure boolean N Forbids JavaScript from accessing the cookie. If not set, the default is false.
httpOnly boolean N Indicates the cookie was sent to the server when a request was made with an HTTP scheme. If not set, the default is false.

Copied to clipboard.

export interface Cookie {
  name: string;
  value: string;
  path?: string;
  domain?: string;
  version?: string;
  expires?: string;
  secure?: boolean;
  httpOnly?: boolean;
}

Copied to clipboard.

CookieManager.set(url:string, Cookie:object)

Here's an example:

Copied to clipboard.

import { CookieManager } from "@amazon-devices/webview";

CookieManager.set('https://YOUR_URL_HERE.com', {
  name: 'Test-Cookie',
  value: 'Test-Cookie-Value',
  path: '/',
  version: '1',
  expires: '2024-01-01T12:30:00.00-05:00',
}).then((status) => {
  console.log('CookieManager.set =>', status);
});

Copied to clipboard.

CookieManager.clearAll()

Here's an example:

Copied to clipboard.

import { CookieManager } from "@amazon-devices/webview";

CookieManager.clearAll().then((status) => {
    console.log('CookieManager.clearAll =>', status);
});

Notes:

  • The set() method sets a single cookie for the URL.
  • For any existing cookie with the same name, the host and path is replaced. The Domain value sets the host of the cookie as described in this Set-Cookie doc.
  • Setting expired cookies will be ignored.
  • The WebView instance shares the cookie store. It is not shared across different apps. A common engine, which includes the cookie store, shares multiple WebView instances in the same app.
  • The React Native layer of the app cannot read the cookie store at this point.

Last updated: Sep 30, 2025