Skip to main content
Deno 2 is finally here 🎉️
Learn more
Module

x/ayonli_jsext/esm/http.js>setCookie

A JavaScript extension package for building strong and modern applications.
Latest
function setCookie
import { setCookie } from "https://deno.land/x/ayonli_jsext@v0.9.72/esm/http.js";

Sets a cookie in the Set-Cookie header of the response.

NOTE: This function can be used with both Response and Headers objects. However, when using with a Headers instance, make sure to set the cookie before the headers instance is used by the response object.

Examples

Example 1

import { setCookie } from "@ayonli/jsext/http";

export default {
    fetch(req: Request) {
        const res = new Response("Hello, World!");
        setCookie(res, { name: "hello", value: "world" });

        return res;
    }
}

Parameters

res