import { setCookie } from "https://deno.land/x/ayonli_jsext@v0.9.72/http.ts";
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
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;
}
}