Skip to main content
Deno 2 is finally here 🎉️
Learn more
Module

x/xserver/src/mod.ts>Session

X-Server a Deno server module with middleware
Go to Latest
class Session
extends Plugin<boolean>
Re-export
import { Session } from "https://deno.land/x/xserver@5.3.2/src/mod.ts";

Constructors

new
Session(options?: Options)

Properties

iterations: number
key: number
name: string
parse: boolean
realm: string
salt: number
scheme: string
vector: number

Methods

create(context: Context, data: string | Record<string, unknown>): Promise<void>
decrypt(encrypted: string, secret?: string): Promise<string>
destroy(context: Context): void
domain(domain: string): Session

The set-cookie Domain header.

encrypt(data: string, secret?: string): Promise<string>
expiration(expiration: number): Session

The number of milliseconds the session/cookie is valid default is 1 day or 24 hours.

forbidden(forbidden: Forbidden): Session
handle(context: Context, use: boolean): Promise<Response | void>
httpOnly(httpOnly: boolean): Session

The set-cookie HttpOnly header.

sameSite(sameSite: SameSite): Session

The set-cookie SameSite header.

secret(secret: string): Session

The secret to use to encrypt/decrrypt the cookies.

secure(secure: boolean): Session

The set-cookie Secure header.

setup(context: Context): void
sign(
encrypted: string,
stamped: string,
signature?: string,
): Promise<string>
signature(signature: string): Session

The signature to use to sign/unsign the cookies.

stamp(time: number): string
unauthorized(unauthorized: Unauthorized): Session
unsign(
encrypted: string,
stamped: string,
signed: string,
signature?: string,
): Promise<boolean>
unstamp(time: string): boolean
validate(validate: Validate): Session