Socket
Book a DemoInstallSign in
Socket

mega-session

Package Overview
Dependencies
Maintainers
1
Versions
15
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

mega-session

Redis Session Manager

1.3.2
latest
npmnpm
Version published
Weekly downloads
8
Maintainers
1
Weekly downloads
 
Created
Source

Mega Session

A session manager (mainly designed for sveltekit)

Use the built in Redis data provider or create your own for another backend, just implement the Provider interface.

SvelteKit Example

In your hooks.server.ts:

let sm = new SessionManager(
  new InternalProvider(), {
  cookieName: "session_id",
  version: "1",
  timeoutMillis: 1000000,
  jwtSecret: "shhhh!",
})
await sm.init()

export const handle: Handle = async ({ event, resolve }) => {
  // get or create session
  event.locals.session = await sm.startSession(event.cookies.get(sm.options.cookieName));

  let response = await resolve(event);

  // save session
  response.headers.set('set-cookie', await sm.saveSession(event.locals.session))

  return response;
}

// To logout a user in a route:
event.locals.session.logout = true

Session Cleanup

You can run a periodic cleanup by running:

await sm.removeOldSessions()

FAQs

Package last updated on 16 Aug 2025

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

About

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.

  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc

U.S. Patent No. 12,346,443 & 12,314,394. Other pending.