{"id":13395593,"url":"https://github.com/psr7-sessions/storageless","last_synced_at":"2026-01-16T00:17:23.336Z","repository":{"id":1739542,"uuid":"42022232","full_name":"psr7-sessions/storageless","owner":"psr7-sessions","description":":mailbox_with_mail: storage-less PSR-7 session support","archived":false,"fork":false,"pushed_at":"2026-01-10T04:26:48.000Z","size":2696,"stargazers_count":652,"open_issues_count":3,"forks_count":38,"subscribers_count":19,"default_branch":"10.2.x","last_synced_at":"2026-01-11T01:22:45.102Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"PHP","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/psr7-sessions.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,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2015-09-06T23:26:16.000Z","updated_at":"2026-01-10T04:26:51.000Z","dependencies_parsed_at":"2023-09-27T09:32:46.572Z","dependency_job_id":"f0ebc1d6-14a0-4133-ba42-ed1578869eff","html_url":"https://github.com/psr7-sessions/storageless","commit_stats":{"total_commits":945,"total_committers":19,"mean_commits":49.73684210526316,"dds":0.62010582010582,"last_synced_commit":"2a72f0a536a72697b365c5b867895ed6b9097bd0"},"previous_names":[],"tags_count":39,"template":false,"template_full_name":null,"purl":"pkg:github/psr7-sessions/storageless","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/psr7-sessions%2Fstorageless","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/psr7-sessions%2Fstorageless/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/psr7-sessions%2Fstorageless/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/psr7-sessions%2Fstorageless/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/psr7-sessions","download_url":"https://codeload.github.com/psr7-sessions/storageless/tar.gz/refs/heads/10.2.x","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/psr7-sessions%2Fstorageless/sbom","scorecard":{"id":541855,"data":{"date":"2025-08-11","repo":{"name":"github.com/psr7-sessions/storageless","commit":"1d432c532839dfa3991bac49ca661edc3afb94cb"},"scorecard":{"version":"v5.2.1-40-gf6ed084d","commit":"f6ed084d17c9236477efd66e5b258b9d4cc7b389"},"score":4.3,"checks":[{"name":"Code-Review","score":0,"reason":"Found 0/23 approved changesets -- score normalized to 0","details":null,"documentation":{"short":"Determines if the project requires human code review before pull requests (aka merge requests) are merged.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#code-review"}},{"name":"Packaging","score":-1,"reason":"packaging workflow not detected","details":["Warn: no GitHub/GitLab publishing workflow detected."],"documentation":{"short":"Determines if the project is published as a package that others can easily download, install, easily update, and uninstall.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#packaging"}},{"name":"Dangerous-Workflow","score":-1,"reason":"no workflows found","details":null,"documentation":{"short":"Determines if the project's GitHub Action workflows avoid dangerous patterns.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#dangerous-workflow"}},{"name":"Binary-Artifacts","score":10,"reason":"no binaries found in the repo","details":null,"documentation":{"short":"Determines if the project has generated executable (binary) artifacts in the source repository.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#binary-artifacts"}},{"name":"Pinned-Dependencies","score":-1,"reason":"no dependencies found","details":null,"documentation":{"short":"Determines if the project has declared and pinned the dependencies of its build process.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#pinned-dependencies"}},{"name":"Token-Permissions","score":-1,"reason":"No tokens found","details":null,"documentation":{"short":"Determines if the project's workflows follow the principle of least privilege.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#token-permissions"}},{"name":"Maintained","score":10,"reason":"30 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 10","details":null,"documentation":{"short":"Determines if the project is \"actively maintained\".","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#maintained"}},{"name":"CII-Best-Practices","score":0,"reason":"no effort to earn an OpenSSF best practices badge detected","details":null,"documentation":{"short":"Determines if the project has an OpenSSF (formerly CII) Best Practices Badge.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#cii-best-practices"}},{"name":"Security-Policy","score":0,"reason":"security policy file not detected","details":["Warn: no security policy file detected","Warn: no security file to analyze","Warn: no security file to analyze","Warn: no security file to analyze"],"documentation":{"short":"Determines if the project has published a security policy.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#security-policy"}},{"name":"Fuzzing","score":0,"reason":"project is not fuzzed","details":["Warn: no fuzzer integrations found"],"documentation":{"short":"Determines if the project uses fuzzing.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#fuzzing"}},{"name":"Vulnerabilities","score":10,"reason":"0 existing vulnerabilities detected","details":null,"documentation":{"short":"Determines if the project has open, known unfixed vulnerabilities.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#vulnerabilities"}},{"name":"License","score":10,"reason":"license file detected","details":["Info: project has a license file: LICENSE:0","Info: FSF or OSI recognized license: MIT License: LICENSE:0"],"documentation":{"short":"Determines if the project has defined a license.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#license"}},{"name":"Signed-Releases","score":-1,"reason":"no releases found","details":null,"documentation":{"short":"Determines if the project cryptographically signs release artifacts.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#signed-releases"}},{"name":"Branch-Protection","score":0,"reason":"branch protection not enabled on development/release branches","details":["Warn: branch protection not enabled for branch '10.1.x'","Warn: branch protection not enabled for branch 'master'"],"documentation":{"short":"Determines if the default and release branches are protected with GitHub's branch protection settings.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#branch-protection"}},{"name":"SAST","score":0,"reason":"SAST tool is not run on all commits -- score normalized to 0","details":["Warn: 0 commits out of 7 are checked with a SAST tool"],"documentation":{"short":"Determines if the project uses static code analysis.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#sast"}}]},"last_synced_at":"2025-08-20T08:22:43.632Z","repository_id":1739542,"created_at":"2025-08-20T08:22:43.632Z","updated_at":"2025-08-20T08:22:43.632Z"},"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28421212,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-14T10:47:48.104Z","status":"ssl_error","status_checked_at":"2026-01-14T10:46:19.031Z","response_time":107,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"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-07-30T18:00:25.197Z","updated_at":"2026-01-16T00:17:23.330Z","avatar_url":"https://github.com/psr7-sessions.png","language":"PHP","funding_links":[],"categories":["Middleware","PHP","Packages"],"sub_categories":["Session"],"readme":"# PSR-7 Storage-less HTTP Sessions\n\n[![Mutation testing badge](https://img.shields.io/endpoint?style=flat\u0026url=https%3A%2F%2Fbadge-api.stryker-mutator.io%2Fgithub.com%2Fpsr7-sessions%2Fstorageless%2F9.2.x)](https://dashboard.stryker-mutator.io/reports/github.com/psr7-sessions/storageless/9.2.x)\n[![Type Coverage](https://shepherd.dev/github/psr7-sessions/storageless/coverage.svg)](https://shepherd.dev/github/psr7-sessions/storageless)\n[![Packagist](https://img.shields.io/packagist/v/psr7-sessions/storageless.svg)](https://packagist.org/packages/psr7-sessions/storageless)\n[![Packagist](https://img.shields.io/packagist/vpre/psr7-sessions/storageless.svg)](https://packagist.org/packages/psr7-sessions/storageless)\n\n**PSR7Session** is a [PSR-7](https://www.php-fig.org/psr/psr-7/) and\n[PSR-15](https://github.com/php-fig/fig-standards/blob/master/accepted/PSR-15-request-handlers.md)\ncompatible [middleware](https://mwop.net/blog/2015-01-08-on-http-middleware-and-psr-7.html) that enables\nsession without I/O usage in PSR-7 based applications.\n\nProudly brought to you by [ocramius](https://github.com/Ocramius), [malukenho](https://github.com/malukenho) and [lcobucci](https://github.com/lcobucci).\n\n## Installation\n\n```sh\ncomposer require psr7-sessions/storageless\n```\n\n## Usage\n\nYou can use the `PSR7Sessions\\Storageless\\Http\\SessionMiddleware` in any\n[PSR-15](https://github.com/php-fig/fig-standards/blob/master/accepted/PSR-15-request-handlers.md)\ncompatible middleware.\n\nIn a [`mezzio/mezzio`](https://github.com/mezzio/mezzio)\napplication, this would look like following:\n\n```php\nuse Lcobucci\\JWT\\Configuration as JwtConfig;\nuse Lcobucci\\JWT\\Signer;\nuse Lcobucci\\JWT\\Signer\\Key\\InMemory;\nuse PSR7Sessions\\Storageless\\Http\\SessionMiddleware;\nuse PSR7Sessions\\Storageless\\Http\\Configuration as StoragelessConfig;\n\n$app = new \\Mezzio\\Application(/* ... */);\n\n$app-\u003epipe(new SessionMiddleware(\n    StoragelessConfig::fromJwtConfiguration(\n        JwtConfig::forSymmetricSigner(\n            new Signer\\Hmac\\Sha256(),\n            InMemory::base64Encoded('OpcMuKmoxkhzW0Y1iESpjWwL/D3UBdDauJOe742BJ5Q='), // replace this with a key of your own (see below)\n        )\n    )\n));\n```\n\nAfter this, you can access the session data inside any middleware that\nhas access to the `Psr\\Http\\Message\\ServerRequestInterface` attributes:\n\n```php\n$app-\u003eget('/get', function (ServerRequestInterface $request, ResponseInterface $response) : ResponseInterface {\n    $session = $request-\u003egetAttribute(SessionMiddleware::SESSION_ATTRIBUTE);\n    assert($session instanceof \\PSR7Sessions\\Storageless\\Session\\SessionInterface);\n    $session-\u003eset('counter', $session-\u003eget('counter', 0) + 1);\n\n    $response\n        -\u003egetBody()\n        -\u003ewrite('Counter Value: ' . $session-\u003eget('counter'));\n\n    return $response;\n});\n```\n\nYou can do this also in asynchronous contexts and long-running processes,\nsince no super-globals nor I/O are involved.\n\nIt is recommended that you use a key with lots of entropy, preferably\ngenerated using a cryptographically secure pseudo-random number generator\n(CSPRNG). You can use the [CryptoKey tool](https://github.com/AndrewCarterUK/CryptoKey)\nto do this for you.\n\nNote that you can also use asymmetric keys; please refer to\n[`lcobucci/jwt`](https://packagist.org/packages/lcobucci/jwt) documentation:\n\n1. The `Configuration` object: https://lcobucci-jwt.readthedocs.io/en/stable/configuration/\n2. Supported algorithms: https://lcobucci-jwt.readthedocs.io/en/stable/supported-algorithms/\n\n### Session Hijacking mitigation\n\nTo mitigate the risks associated to cookie stealing and thus\n[session hijacking](https://cheatsheetseries.owasp.org/cheatsheets/Session_Management_Cheat_Sheet.html#binding-the-session-id-to-other-user-properties),\nyou can bind the user session to its IP (`$_SERVER['REMOTE_ADDR']`) and\nUser-Agent (`$_SERVER['HTTP_USER_AGENT']`) by enabling client fingerprinting:\n\n```php\nuse PSR7Sessions\\Storageless\\Http\\SessionMiddleware;\nuse PSR7Sessions\\Storageless\\Http\\Configuration as StoragelessConfig;\nuse PSR7Sessions\\Storageless\\Http\\ClientFingerprint\\Configuration as FingerprintConfig;\n\n$app = new \\Mezzio\\Application(/* ... */);\n\n$app-\u003epipe(new SessionMiddleware(\n    StoragelessConfig::fromJwtConfiguration(/* ... */)\n        -\u003ewithClientFingerprintConfiguration(\n            FingerprintConfig::forIpAndUserAgent()\n        )\n));\n```\n\nIf your PHP service is behind a reverse proxy of yours, [you may need to retrieve the client IP from a different source of truth](https://adam-p.ca/blog/2022/03/x-forwarded-for/).\nIn such cases you can extract the information you need by writing a custom\n`\\PSR7Sessions\\Storageless\\Http\\ClientFingerprint\\Source` implementation:\n\n```php\nuse Psr\\Http\\Message\\ServerRequestInterface;\nuse PSR7Sessions\\Storageless\\Http\\SessionMiddleware;\nuse PSR7Sessions\\Storageless\\Http\\Configuration as StoragelessConfig;\nuse PSR7Sessions\\Storageless\\Http\\ClientFingerprint\\Configuration as FingerprintConfig;\nuse PSR7Sessions\\Storageless\\Http\\ClientFingerprint\\Source;\n\n$app = new \\Mezzio\\Application(/* ... */);\n\n$app-\u003epipe(new SessionMiddleware(\n    StoragelessConfig::fromJwtConfiguration(/* ... */)\n        -\u003ewithClientFingerprintConfiguration(\n            FingerprintConfig::forSources(new class implements Source{\n                 public function extractFrom(ServerRequestInterface $request): string\n                 {\n                     return $request-\u003egetHeaderLine('X-Real-IP');\n                 }\n            })\n        )\n));\n```\n\n### Examples\n\nSimply browse to the `examples` directory in your console, then run\n\n```sh\nphp -S localhost:9999 index.php\n```\n\nThen try accessing `http://localhost:9999`: you should see a counter\nthat increases at every page refresh\n\n## WHY?\n\nIn most PHP+HTTP related projects, `ext/session` serves its purpose and\nallows us to store server-side information by associating a certain\nidentifier to a visiting user-agent.\n\n## What is the problem with `ext/session`?\n\nThis is all fair and nice, except for:\n\n* relying on the `$_SESSION` superglobal\n* relying on the shutdown handlers in order to \"commit\" sessions to the\n  storage\n* having a huge limitation of number of active users (due to storage)\n* having a lot of I/O due to storage\n* having serialized data cross different processes (PHP serializes and\n  de-serializes `$_SESSION` for you, and there are security implications)\n* having to use a centralized storage for setups that scale horizontally\n* having to use sticky sessions (with a \"smart\" load-balancer) when the\n  storage is not centralized\n* not designed to be used for multiple dispatch cycles\n\n## What does this project do?\n\nThis project tries to implement storage-less sessions and to mitigate the\nissues listed above.\n\n## Assumptions\n\n* your sessions are fairly small and contain only few identifiers and\n  some CSRF tokens. Small means `\u003c 400` bytes\n* data in your session is `JsonSerializable` or equivalent\n* data in your session is **freely readable by the client**\n\n## How does it work?\n\nSession data is directly stored inside a session cookie as a JWT token.\n\nThis approach is not new, and is commonly used with `Bearer` tokens in\nHTTP/REST/OAuth APIs.\n\nIn order to guarantee that the session data is not modified, that the\nclient can trust the information and that the expiration date is\nmutually agreed between server and client, a [JWT token](https://tools.ietf.org/html/rfc7519)\nis used to transmit the information.\n\nThe JWT token is always signed to ensure that the user-agent is never\nable to manipulate the session.\nBoth symmetric and asymmetric keys are supported for signing/verifying\ntokens.\n\n## Advantages\n\n* no storage required\n* no sticky sessions required (any server having a copy of the private or\n  public keys can generate sessions or consume them)\n* can transmit cleartext information to the client, allowing it to share\n  some information with the server (a standard example is about sharing the\n  \"username\" or \"user-id\" in a given session)\n* can transmit encrypted information to the client, allowing server-only\n  consumption of the information\n* not affected by PHP serialization RCE attacks\n* not limited to PHP process scope: can have many sessions per process\n* no reliance on global state\n* when in a multi-server setup, you may allow read-only access to servers\n  that only have access to public keys, while writes are limited to\n  servers that have access to private keys\n* can be used over multiple dispatch cycles\n\n## Configuration options\n\nPlease refer to the [configuration documentation](docs/configuration.md).\n\n## Known limitations\n\nPlease refer to the [limitations documentation](docs/limitations.md).\n\n## Contributing\n\nPlease refer to the [contributing notes](CONTRIBUTING.md).\n\n## License\n\nThis project is made public under the [MIT LICENSE](LICENSE).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpsr7-sessions%2Fstorageless","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpsr7-sessions%2Fstorageless","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpsr7-sessions%2Fstorageless/lists"}