{"id":22138186,"url":"https://github.com/peerigon/socket.io-session-middleware","last_synced_at":"2025-07-29T20:36:53.055Z","repository":{"id":57365202,"uuid":"20733805","full_name":"peerigon/socket.io-session-middleware","owner":"peerigon","description":"share connect/express sessions with socket.io","archived":false,"fork":false,"pushed_at":"2020-08-27T12:39:00.000Z","size":8,"stargazers_count":18,"open_issues_count":1,"forks_count":6,"subscribers_count":17,"default_branch":"master","last_synced_at":"2024-10-31T17:58:30.536Z","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":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/peerigon.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2014-06-11T17:14:26.000Z","updated_at":"2022-02-02T11:20:32.000Z","dependencies_parsed_at":"2022-09-15T16:10:19.990Z","dependency_job_id":null,"html_url":"https://github.com/peerigon/socket.io-session-middleware","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/peerigon%2Fsocket.io-session-middleware","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/peerigon%2Fsocket.io-session-middleware/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/peerigon%2Fsocket.io-session-middleware/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/peerigon%2Fsocket.io-session-middleware/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/peerigon","download_url":"https://codeload.github.com/peerigon/socket.io-session-middleware/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":227563193,"owners_count":17787057,"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","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-12-01T20:08:51.151Z","updated_at":"2024-12-01T20:08:51.653Z","avatar_url":"https://github.com/peerigon.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"## socket.io-session-middleware\n\nShare connect/express sessions with socket.io 1.x\n\n## Setup\n\n[![npm status](https://nodei.co/npm/socket.io-session-middleware.png?downloads=true\u0026stars=true)](https://npmjs.org/package/socket.io-session-middleware)\n\n[![Dependency Status](https://david-dm.org/peerigon/socket.io-session-middleware.svg)](https://david-dm.org/peerigon/socket.io-session-middleware)\n\n## Example\n\n**Server**\n\n```javascript\nvar socketSession = require(\"socket.io-session-middleware\");\n\nvar session = {\n  store: new connect.session.MemoryStore(),\n  secret: \"secret\",\n  key: \"mykey.sid\",\n  cookieParser: connect.cookieParser(\"secret\"),\n};\n\nio.use(socketSession(session));\n\nio.on(\"connection\", function (socket) {\n  socket.on(\"whoAreYou\", function (callback) {\n    //read from session\n    callback(socket.session.name);\n  });\n\n  socket.on(\"setName\", function (data) {\n    //write to session\n    socket.session.name = data.name;\n  });\n});\n```\n\n**Client**\n\n```javascript\nsocket.emit(\"setName\", { name: \"hans\" });\n\nsocket.emit(\"whoAreYou\", function (name) {\n  console.log(\"I am \" + name);\n});\n\n//=\u003e I am hans\n```\n\nA full featured example can be found in the _example_ folder.\n\n## Notes\n\nMake sure to fire a http request to initialize the session/cookie before accessing the session with socket.io.\nIf you are serving the socket.io client with your node.js server this won't be a problem for you.\n\n## Sponsors\n\n[\u003cimg src=\"https://assets.peerigon.com/peerigon/logo/peerigon-logo-flat-spinat.png\" width=\"150\" /\u003e](https://peerigon.com)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpeerigon%2Fsocket.io-session-middleware","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpeerigon%2Fsocket.io-session-middleware","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpeerigon%2Fsocket.io-session-middleware/lists"}