Options
All
  • Public
  • Public/Protected
  • All
Menu

Class Session

Represents a browser session.

Sessions persist between HTTP requests for a single browser session. They are deleted when the browser is closed, or they time-out. Session cookies are used to maintain sessions using a secure UUID.

Sessions can be used to maintain data for a browser session, e.g. a shopping basket.

The context must have first been routed to a SessionHandler for sessions to be available.

Hierarchy

  • Session

Index

Methods

computeIfAbsent

  • computeIfAbsent(key: string, mappingFunction: (arg: string) => any): Session
  • Put some data in a session if absent.

    If the specified key is not already associated with a value (or is mapped to null), attempts to compute its value using the given mapping function and enters it into this map unless null.

    Parameters

    • key: string
    • mappingFunction: (arg: string) => any
        • (arg: string): any
        • Parameters

          • arg: string

          Returns any

    Returns Session

data

  • data(): {}
  • Returns {}

    • [key: string]: any

destroy

  • destroy(): void
  • Destroy the session

    Returns void

get

  • get<T>(key: string): T
  • Get some data from the session

    Type parameters

    • T

    Parameters

    • key: string

    Returns T

id

  • id(): string
  • Returns string

isDestroyed

  • isDestroyed(): boolean
  • Returns boolean

isEmpty

  • isEmpty(): boolean
  • Returns boolean

isRegenerated

  • isRegenerated(): boolean
  • Returns boolean

lastAccessed

  • lastAccessed(): number
  • Returns number

oldId

  • oldId(): string
  • Returns string

put

  • put(key: string, obj: any): Session
  • Put some data in a session

    Parameters

    • key: string
    • obj: any

    Returns Session

putIfAbsent

  • putIfAbsent(key: string, obj: any): Session
  • Put some data in a session if absent

    Parameters

    • key: string
    • obj: any

    Returns Session

regenerateId

  • Returns Session

remove

  • remove<T>(key: string): T
  • Remove some data from the session

    Type parameters

    • T

    Parameters

    • key: string

    Returns T

setAccessed

  • setAccessed(): void
  • Mark the session as being accessed.

    Returns void

timeout

  • timeout(): number
  • Returns number

value

  • value(): string
  • The short representation of the session to be added to the session cookie. By default is the session id.

    Returns string

Generated using TypeDoc