Skip to main content
Deno 2 is finally here 🎉️
Learn more
Go to Latest
function signCookie
import { signCookie } from "https://deno.land/x/fathym_eac_runtime@v0.0.140/src/src.deps.ts";

Returns a promise with the signed cookie value from the given cryptographic key.

Examples

Example 1

import { signCookie } from "https://deno.land/std@0.224.0/http/unstable_signed_cookie.ts";
import { setCookie } from "https://deno.land/std@0.224.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

value: string

Returns

Promise<string>