async function cookieTest() {
// Set test cookie
try {
await cookieStore.set("cookie1", "cookie1-value");
} catch (error) {
console.log(`Error setting cookie1: ${error}`);
}
// Get cookie, specifying name
const cookie = await cookieStore.get("cookie1");
if (cookie) {
console.log(cookie);
} else {
console.log("cookie1: Cookie not found");
}
}
cookieTest();CookieStore: get() method / notebook
CookieStore: get() method
Runnable notebook: every JavaScript, HTML and CSS example on this page executes in a sandboxed local frame. Nothing leaves the browser.