Skip to main content
Module

x/deno_kv_oauth/mod.ts>getSessionId

High-level OAuth 2.0 powered by Deno KV.
Go to Latest
function getSessionId
Re-export
import { getSessionId } from "https://deno.land/x/deno_kv_oauth@v0.9.0/mod.ts";

Gets the session ID for a given request. This is well-suited for checking whether the client is signed in by checking if undefined.

It does this by getting the session ID from the cookie in the given request. If the request has no cookie, undefined is returned.

Examples

Example 1

import { getSessionId } from "https://deno.land/x/deno_kv_oauth@$VERSION/mod.ts";

export function handler(request: Request) {
  const sessionId = getSessionId(request);
  const hasSessionIdCookie = sessionId !== undefined;

  return Response.json({ sessionId, hasSessionIdCookie });
}

Parameters

request: Request

The HTTP request from the client.