npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2025 – Pkg Stats / Ryan Hefner

kow-sessions

v1.0.2

Published

A compact redis session manager that lets you create, get, update, refresh and kill sessions.

Readme

Kow Sessions

Kow Sessions will help you manage your users' sessions by letting you easily create, fetch, refresh, update and kill sessions. It even lets you kill all sessions owned by a user at once.

It is built on top of ioredis for lightning speed operations.

I've built this package for the sake of simplicity, but I also exposed the Redis client through the package so you can also use all advanced features that redis offers without having the need to install both this package and a redis client.

Disclaimer

This is not a production ready package (although it is pretty straight-forward).

Installation

yarn add kow-sessions

or

npm install kow-sessions

Features

  • create: Creates a session by providing an app name, a ownerId and custom data to be stored with the session. Returns a token.
  • get: Gets the owner and custom data of a specific token + app name combo. Returns undefined if the session is not found.
  • refresh: Refreshes the duration of a specific session. Returns true if the session was refreshed or false if it was not found.
  • update: Updates the custom data of an existing session. Returns true if the session was updated or false if it was not found.
  • kill: Kills an existing session. Returns true if the session was killed or false if it was not found.
  • killAll: Kills all sessions of the same user. Returns true if all sessions were killed or false if no sessions were found.

Going Further

  • client: An ioredis client is exposed within KowSessions class so you can use all advanced features of redis you wish.

Usage

Instantiate the client

// Pass an optional connection string to the constructor
// new KowSessions('redis://localhost:6379')
const kow = new KowSessions();

Create a session

const kow = new KowSessions();

const token = await kow.create({
  app: 'my-app',
  ownerId: '123qwe',
  data: { 
    firstName: 'John',
    lastName: 'Doe',
    currentDeviceToken: '123'
  },
  duration: 3600
);

Gets a session

const kow = new KowSessions();

const { ownerId, data } = await kow.get({
  app: 'my-app',
  token: 'qwerty',
);

Refreshes a session

const kow = new KowSessions();

const success = await kow.refresh({
  app: 'my-app',
  token: 'qwerty',
  duration: 7200
);

Updates a session

const kow = new KowSessions();

const success = await kow.update({
  app: 'my-app',
  token: 'qwerty',
  data: {
    name: null, // Use null to delete existing values
    age: 25
  }
);

Kills a session

const kow = new KowSessions();

const success = await kow.kill({
  app: 'my-app',
  token: 'qwerty'
);

Kills all sessions of a user

const kow = new KowSessions();

const success = await kow.killAll({
  app: 'my-app',
  ownerId: '123qwe'
);

Contributing

Feel free to contribute in any way you'd like. You can email me at [email protected] if you have any questions.