{"id":19327691,"url":"https://github.com/antidot-framework/session-middleware","last_synced_at":"2026-05-16T09:08:59.626Z","repository":{"id":46013238,"uuid":"181949327","full_name":"antidot-framework/session-middleware","owner":"antidot-framework","description":"Antidot Framework session library","archived":false,"fork":false,"pushed_at":"2021-11-20T09:08:51.000Z","size":25,"stargazers_count":1,"open_issues_count":1,"forks_count":1,"subscribers_count":1,"default_branch":"1.x.x","last_synced_at":"2025-05-02T07:53:15.883Z","etag":null,"topics":["antidot-framework","psr-11","psr-15"],"latest_commit_sha":null,"homepage":"https://antidotfw.io/","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"bsd-2-clause","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/antidot-framework.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":".github/FUNDING.yml","license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null},"funding":{"github":"kpicaza"}},"created_at":"2019-04-17T18:42:56.000Z","updated_at":"2021-11-20T09:08:55.000Z","dependencies_parsed_at":"2022-09-21T11:11:52.132Z","dependency_job_id":null,"html_url":"https://github.com/antidot-framework/session-middleware","commit_stats":null,"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"purl":"pkg:github/antidot-framework/session-middleware","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/antidot-framework%2Fsession-middleware","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/antidot-framework%2Fsession-middleware/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/antidot-framework%2Fsession-middleware/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/antidot-framework%2Fsession-middleware/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/antidot-framework","download_url":"https://codeload.github.com/antidot-framework/session-middleware/tar.gz/refs/heads/1.x.x","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/antidot-framework%2Fsession-middleware/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":33096608,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-16T04:41:52.686Z","status":"ssl_error","status_checked_at":"2026-05-16T04:41:52.009Z","response_time":115,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5: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":["antidot-framework","psr-11","psr-15"],"created_at":"2024-11-10T02:18:10.506Z","updated_at":"2026-05-16T09:08:59.592Z","avatar_url":"https://github.com/antidot-framework.png","language":"PHP","funding_links":["https://github.com/sponsors/kpicaza"],"categories":[],"sub_categories":[],"readme":"# Antidot Session Middleware\n\n[![link-packagist](https://img.shields.io/packagist/v/antidot-fw/session.svg?style=flat-square)](https://packagist.org/packages/antidot-fw/session)\n[![Scrutinizer Code Quality](https://scrutinizer-ci.com/g/antidot-framework/session-middleware/badges/quality-score.png?b=1.x.x)](https://scrutinizer-ci.com/g/antidot-framework/session-middleware/?branch=1.x.x)\n[![Infection MSI](https://badge.stryker-mutator.io/github.com/antidot-framework/session-middleware/1.x.x)](https://infection.github.io)\n[![Code Coverage](https://scrutinizer-ci.com/g/antidot-framework/session-middleware/badges/coverage.png?b=1.x.x)](https://scrutinizer-ci.com/g/antidot-framework/session-middleware/?branch=1.x.x)\n[![type-coverage](https://shepherd.dev/github/antidot-framework/react-framework/coverage.svg)](https://shepherd.dev/github/antidot-framework/react-framework)\n[![Build Status](https://scrutinizer-ci.com/g/antidot-framework/session-middleware/badges/build.png?b=1.x.x)](https://scrutinizer-ci.com/g/antidot-framework/session-middleware/build-status/1.x.x)\n\nPSR-15 middleware that allows having session inside the request attributes.\n\n## Install\n\nInstall using composer, by default it uses an implementation of [Aura Session](https://github.com/auraphp/Aura.Session).\n\n```bash\ncomposer require antidot-fw/session\n```\n\n## Config\n\nUsing [Antidot Framework Starter](), it will work after adding the middleware to the pipeline. Also, you can use it in any\nPSR-15 compatible middleware pipeline using PSR-11 container.\n\n```php\n\u003c?php\n\n$sessionFactory = new AuraSessionFactory();\n$sessionMiddleware = new SessionMiddleware($sessionFactory($container));\n```\n\nAdd it to your pipeline\n\n```php\n\u003c?php\n\nuse Antidot\\Application\\Http\\Application;\nuse Antidot\\Application\\Http\\Middleware\\RouteDispatcherMiddleware;\nuse Antidot\\Session\\Application\\Http\\Middleware\\SessionMiddleware;\n...\n\nreturn static function (Application $app) : void {\n    $app-\u003epipe(...);\n    $app-\u003epipe(SessionMiddleware::class); // added here\n    $app-\u003epipe(RouteDispatcherMiddleware::class);\n    ...\n};\n\n```\n\n## Usage\n\nThe session will be stored as request attribute, For example using a Request handler, and it will be available in middleware \nloaded after it too.\n\n```php\n\u003c?php\n// src/Handler/SomeHandler.php\n\ndeclare(strict_types=1);\n\nnamespace App\\Handler;\n\nuse Psr\\Http\\Message\\ResponseInterface;\nuse Psr\\Http\\Message\\ServerRequestInterface;\nuse Psr\\Http\\Server\\RequestHandlerInterface;\nuse Zend\\Diactoros\\Response\\HtmlResponse;\n\nclass SomeHandler implements RequestHandlerInterface\n{\n\n    public function handle(ServerRequestInterface $request): ResponseInterface\n    {\n        /** @var \\Antidot\\Session\\Application\\Http\\SessionSegment $session */\n        $session = $request-\u003egetAttribute('session');\n\n        $session-\u003eset('foo', 'bar');\n        $session-\u003eset('baz', 'dib');\n        $message = $session-\u003eget('foo'); // 'bar'\n        $message = $session-\u003eget('baz'); // 'dib'\n        $session-\u003esetFlash('message', 'Hello world!');\n        $message = $session-\u003egetFlash('message'); // 'Hello world!'\n        ...\n    }\n}\n```\n\n## Adding custom session implementation\n\nTo create a wrapper for your own custom session, you need to implement both `Antidot\\Session\\Application\\Http\\SessionSegment` \nand  `Antidot\\Session\\Application\\Http\\SessionSegmentFactory` clases, take a look to the \n`Antidot\\Session\\Infrastructure\\AuraSessionSegment` and `Antidot\\Session\\Infrastructure\\AuraSessionSegmentFactory`.\n\n```php\n\u003c?php\n\ndeclare(strict_types=1);\n\nnamespace Antidot\\Session\\Application\\Http;\n\ninterface SessionSegment\n{\n    public function get(string $identity);\n    public function getFlash(string $identity);\n    public function set(string $identity, $value): void;\n    public function setFlash(string $identity, $value): void;\n}\n```\n\n```php\n\u003c?php\n\ndeclare(strict_types=1);\n\nnamespace Antidot\\Session\\Application\\Http;\n\nuse Psr\\Http\\Message\\ServerRequestInterface;\n\ninterface SessionSegmentFactory\n{\n    public function __invoke(ServerRequestInterface $request): SessionSegment;\n}\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fantidot-framework%2Fsession-middleware","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fantidot-framework%2Fsession-middleware","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fantidot-framework%2Fsession-middleware/lists"}