{"id":15290207,"url":"https://github.com/npm/redsess","last_synced_at":"2025-10-07T03:31:56.449Z","repository":{"id":3106937,"uuid":"4133025","full_name":"npm/redsess","owner":"npm","description":"Yet another redis session thing for node.","archived":true,"fork":false,"pushed_at":"2014-04-22T22:25:06.000Z","size":391,"stargazers_count":30,"open_issues_count":2,"forks_count":13,"subscribers_count":30,"default_branch":"master","last_synced_at":"2025-09-28T16:46:17.726Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":"peninquen/Modbus-Energy-Monitor-Arduino","license":"isc","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/npm.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2012-04-25T04:51:02.000Z","updated_at":"2023-04-28T08:57:53.000Z","dependencies_parsed_at":"2022-09-26T16:21:18.939Z","dependency_job_id":null,"html_url":"https://github.com/npm/redsess","commit_stats":null,"previous_names":["isaacs/redsess"],"tags_count":19,"template":false,"template_full_name":null,"purl":"pkg:github/npm/redsess","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/npm%2Fredsess","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/npm%2Fredsess/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/npm%2Fredsess/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/npm%2Fredsess/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/npm","download_url":"https://codeload.github.com/npm/redsess/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/npm%2Fredsess/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":278715722,"owners_count":26033328,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-10-07T02:00:06.786Z","response_time":59,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-09-30T16:06:18.160Z","updated_at":"2025-10-07T03:31:56.148Z","avatar_url":"https://github.com/npm.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# redsess\n\nYet another redis session thing for node.\n\nThis is built on top of [jed/cookies](https://github.com/jed/cookies).\nYou can optionally pass in a KeyGrip instance, or an array of keys to\nuse to sign cookies.\n\n## Breaking Changes in 1.0.0\n\nSessions are now stored as stringified JSON objects using `set` and `get`.\nThis means that *all sessions that were created using previous versions of\nredsess will need to be cleared out/nuked/obliterated*. Before upgrading\nto 1.0.0, let your users know that their sessions will be removed!\n\n## Example\n\n```javascript\nvar RedSess = require('redsess')\n, http = require('http')\n, Cookies = require('cookies')\n, Keygrip = require('keygrip')\n, keys = new Keygrip(['some secret keys here'])\n\n// Create a client with the options that you'd pass to node_redis\nRedSess.createClient(redisOptions)\n\nhttp.createServer(function (req, res) {\n  var session = new RedSess(req, res, {\n    keys: keys, // if keys are provided, they'll be used\n    cookieName: 's',\n    expire: expirationInSeconds, // default = 2 weeks\n    client: redisClient, // defaults to RedSess.client\n    keys: [ \"this is a string key\" ], // will be made into a keygrip obj\n    keys: new KeyGrip(keys), // this way also works\n  })\n\n  // you can decorate like this if you chose\n  req.session = session\n  res.session = session\n\n  // .. and then some time later ..\n  req.session.get('auth', function (er, auth) {\n    if (!auth) {\n      // redirect to login page\n    } else {\n      // do authorized login things\n    }\n  })\n\n  // .. on the login page, if there's a post ..\n  validateLogin(postedData, function (er, isValid) {\n    if (isValid)\n      req.session.set('auth', postedData)\n  })\n\n  // .. on the logout page ..\n  req.session.del('auth', function (er) {\n    // user is now logged out\n  })\n}).listen(1337)\n```\n\n## Constructor Options\n\n* `expire` {Number} Time in seconds that sessions last Default=2 weeks\n* `cookieName` {String} Cookie name to use for session id's. Default = 's'\n* `keys` A [Keygrip](https://github.com/jed/keygrip) instance to use\n  to sign the session token cookie.  (If an array is passed in, then\n  RedSess will make a KeyGrip obj out of it.)\n* `client` If you have another redis client you'd like to use, then\n  you can do so.\n* `cookies` If you already have a Cookies object, you may pass that\n  in.  If not specified, then it'll make a new one for you.\n* `cookieOptions` an object that extends the options object that is passed to\n  `cookies.set` and `cookies.get`\n\n## Methods\n\nCallbacks are all the standard `cb(er, result)` style.\n\nDeep objects are supported, but cycles in data objects will cause\nterrible explosively bad awful undefined behavior, so DON'T DO THAT.\n\n* RedSess.createClient(opts)\n\nCalls `redis.createClient` with the supplied options.  See\n[node_redis](https://github.com/mranney/node_redis) for more details.\n(opts.host and opts.port are passed to redis.createClient as positional\narguments, not on the configuration object.)\n\nIf there's an `opts.auth` member, then it will use that string as a\npassword to redis.\n\n* session.set(k, v, cb)\n\nSets a key on the session.\n\n* session.set(object, cb)\n\nSets a hash of keys and values on the session.\n\n* session.get(k, cb)\n\nFetches the key from the session.\n\n* session.get(cb)\n\nFetches all keys from the session.  If there is no data in the\nsession, then it'll return `null`.\n\n* session.del(k, cb)\n\nDeletes a key from the session.\n\n* session.del(cb)\n\nDeletes the entire session.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnpm%2Fredsess","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fnpm%2Fredsess","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnpm%2Fredsess/lists"}