Skip to content

Files

This branch is 33 commits behind netlify/edge-functions-examples:main.

cookies-read

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
Aug 1, 2022
Jul 22, 2022

Netlify examples

Read, write, and delete cookies with Netlify Edge Functions

Manipulate HTTP cookies

Code example

Edge Functions are files held in the netlify/edge-functions directory.

import type { Context } from "https://edge.netlify.com";

export default async (request: Request, context: Context) => {
  // Set a cookie
  context.cookies.set({
    name: "My cookie",
    value: "hello",
  });

  // Delete a cookie
  context.cookies.delete("My cookie");

  // Read the value of a cookie
  const value = context.cookies.get("My cookie");
};

View this example on the web

Deploy to Netlify

You can deploy this and all the other examples in this repo as a site of your own to explore and experiment with, by clicking this button.

Deploy to Netlify