{"id":49341,"library":"session-cache","title":"session-cache","description":"Session storage for tasks, designed to pass data between gulp tasks or similar workflow steps. Current stable version is 0.2.0, released in 2015 with no updates since. It provides a simple context-based session object to store and retrieve key-value pairs, with methods to bind functions and EventEmitters. Lacks TypeScript support, tests, and modern ESM compatibility. Alternatives include async hooks or more maintained session libraries.","status":"maintenance","version":"0.2.0","language":"javascript","source_language":"en","source_url":"git://github.com/doowb/session-cache","tags":["javascript"],"install":[{"cmd":"npm install session-cache","lang":"bash","label":"npm"},{"cmd":"yarn add session-cache","lang":"bash","label":"yarn"},{"cmd":"pnpm add session-cache","lang":"bash","label":"pnpm"}],"dependencies":[],"imports":[{"note":"The package exports a factory function via module.exports, so it can be imported as a default import in ESM or required directly.","wrong":"const { session } = require('session-cache')","symbol":"default","correct":"import session from 'session-cache'"},{"note":"CommonJS require returns the factory function directly; there is no named export.","wrong":"const { createSession } = require('session-cache')","symbol":"require","correct":"const session = require('session-cache')"},{"note":"The function returned by require/import is a factory that creates a session instance; do not use 'new'.","wrong":"new session('my-app')","symbol":"factory","correct":"session('my-app')"}],"quickstart":{"code":"// Create a session instance\nconst session = require('session-cache')('my-app');\n\n// Set and get values\nsession.set('key', 'value');\nconsole.log(session.get('key')); // 'value'\n\n// Bind a function to the session context\nfunction myTask(data, next) {\n  console.log(this.get('key'));\n  next();\n}\nsession.bind(myTask);\n\n// Bind an EventEmitter\nconst EventEmitter = require('events');\nconst emitter = new EventEmitter();\nsession.bindEmitter(emitter);","lang":"javascript","description":"Demonstrates creating a session, setting/getting values, binding a function, and binding an EventEmitter."},"warnings":[{"fix":"Validate session names and keys to avoid code injection.","message":"The package uses `new Function` internally which can be unsafe if untrusted input is passed to session names or keys.","severity":"gotcha","affected_versions":">=0.0.0"},{"fix":"Create a .d.ts file or use type assertions.","message":"No TypeScript definitions available; manual type declaration needed.","severity":"gotcha","affected_versions":">=0.0.0"},{"fix":"Consider migrating to an actively maintained session library.","message":"The package is unmaintained since 2015 and may have unpatched vulnerabilities.","severity":"gotcha","affected_versions":">=0.0.0"},{"fix":"Use dynamic import if needed in ESM: `const session = (await import('session-cache')).default;`","message":"Uses `require('session-cache')` which is CommonJS; no ESM export.","severity":"deprecated","affected_versions":">=0.0.0"}],"env_vars":null,"search_vec":"'0.2.0':23 '2015':26 'altern':63 'async':65 'base':37 'bind':51 'cach':3 'compat':62 'context':36 'context-bas':35 'current':19 'data':11 'design':8 'esm':61 'eventemitt':54 'function':52 'gulp':13 'hook':66 'includ':64 'javascript':72 'key':45 'key-valu':44 'lack':55 'librari':71 'maintain':69 'method':49 'modern':60 'object':39 'pair':47 'pass':10 'provid':32 'releas':24 'retriev':43 'session':2,4,38,70 'session-cach':1 'similar':16 'simpl':34 'sinc':30 'stabl':20 'step':18 'storag':5 'store':41 'support':57 'task':7,14 'test':58 'typescript':56 'updat':29 'valu':46 'version':21 'workflow':17","created_at":"2026-06-07T17:01:15.851692+00:00","updated_at":"2026-06-07T17:01:15.851692+00:00","problems":[{"fix":"Use `const session = require('session-cache');` or `import session from 'session-cache';`","cause":"Importing the module incorrectly, e.g. using named import when only default export exists.","error":"TypeError: session is not a function"},{"fix":"Run `npm i session-cache --save` and ensure the package name is correct.","cause":"Package not installed or typo in package name.","error":"Cannot find module 'session-cache'"},{"fix":"Ensure you call `session.bind(fn)` and that `fn` is invoked with the correct `this`.","cause":"Using `bind` on a function that is not called within the session context properly.","error":"TypeError: this.get is not a function"}],"ecosystem":"npm","meta_description":null,"install_score":null,"quickstart_score":null,"quickstart_tag":null,"pypi_latest":null,"cli_name":null,"cli_version":null,"type":"library","homepage":"https://github.com/doowb/session-cache","github":"git://github.com/doowb/session-cache","docs":null,"changelog":null,"pypi":null,"npm":"session-cache","openapi_spec":null,"status_page":null,"smithery":null,"categories":["storage"],"base_url":null,"auth_type":null,"provenance":{"verified_status":null,"verified_at":null,"last_verified":"2026-06-07","next_check":"2026-09-05","install_tag":null}}