Session

The session module for PXE.js

Installation

Install @pxe/session.

# NPM npm i @pxe/session # Yarn yarn add @pxe/session

Constructor: Session

Create a session instance.

Method: session.invoke

  • ctx: Context:
  • next: NextFunction:
  • ...args: any[]:

The callback of the session middleware. This can be used as a middleware:

app.use(session.invoke.bind(router)); // Or shorter app.use(session);

Session Store

Store the sessions. The default session store can cause memory leaks.

Constructor: Store

Create a new session store.

Method: sessionStore.save

  • data: any: Data to be stored
  • id: string: The id

Save data and id to sessionStore matching id.

Method: sessionStore.get

  • id: string: The id

Get the sessionStore.

Method: sessionStore.destroy

  • id: string: The id

Destroy the sessionStore.