import { signCookie } from "https://deno.land/std@0.212.0/http/unstable_signed_cookie.ts";
Returns a promise with the signed cookie value from the given cryptographic key.
Examples
Example 1
Example 1
import { signCookie } from "https://deno.land/std@0.212.0/http/unstable_signed_cookie.ts";
import { setCookie } from "https://deno.land/std@0.212.0/http/cookie.ts";
const key = await crypto.subtle.generateKey(
{ name: "HMAC", hash: "SHA-256" },
true,
["sign", "verify"],
);
const value = await signCookie("my-cookie-value", key);
const headers = new Headers();
setCookie(headers, {
name: "my-cookie-name",
value,
});
const cookieHeader = headers.get("set-cookie");
Parameters
key: CryptoKey