Skip to main content

@std/http@0.215.0

latest
Works with
It is unknown whether this package works with Browsers, Deno, Node.js, Cloudflare Workers, Bun
It is unknown whether this package works with Browsers
It is unknown whether this package works with Deno
It is unknown whether this package works with Node.js
It is unknown whether this package works with Cloudflare Workers
It is unknown whether this package works with Bun
JSR Score70%
Published2 years ago (0.215.0)
function parseSignedCookie
parseSignedCookie(signedCookie: string): string

Parses a signed cookie to get its value.

Important: always verify the cookie using verifyCookie first.

Examples

Example 1

import { verifyCookie, parseSignedCookie } from "@std/http/unstable_signed_cookie";
import { getCookies } from "@std/http/cookie";

const key = await crypto.subtle.generateKey(
  { name: "HMAC", hash: "SHA-256" },
  true,
  ["sign", "verify"],
);

const headers = new Headers({
  Cookie: "location=tokyo.37f7481039762eef5cd46669f93c0a3214dfecba7d0cdc0b0dc40036063fb22e",
});
const signedCookie = getCookies(headers)["location"];
await verifyCookie(signedCookie, key);
const cookie = parseSignedCookie(signedCookie);

Parameters

signedCookie: string

Return Type

Report package

Please provide a reason for reporting this package. We will review your report and take appropriate action.

Please review the JSR usage policy before submitting a report.

Add Package

deno add jsr:@std/http

Import symbol

import { parseSignedCookie } from "@std/http";
or

Import directly with a jsr specifier

import { parseSignedCookie } from "jsr:@std/http";