{"id":23107937,"url":"https://github.com/andrewdyer/slim3-session-middleware","last_synced_at":"2025-08-16T17:32:03.896Z","repository":{"id":56948017,"uuid":"126739777","full_name":"andrewdyer/slim3-session-middleware","owner":"andrewdyer","description":"Simple session middleware for the Slim Framework. Also included is a useful helper class that allows PHP built-in session management.","archived":true,"fork":false,"pushed_at":"2024-12-22T17:53:38.000Z","size":18,"stargazers_count":6,"open_issues_count":0,"forks_count":1,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-05-08T03:18:03.630Z","etag":null,"topics":["middleware","php","session","session-management","session-middleware","slim","slim-framework","slim3"],"latest_commit_sha":null,"homepage":"","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/andrewdyer.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2018-03-25T20:59:57.000Z","updated_at":"2024-12-22T17:54:32.000Z","dependencies_parsed_at":"2022-08-21T07:20:59.656Z","dependency_job_id":null,"html_url":"https://github.com/andrewdyer/slim3-session-middleware","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"purl":"pkg:github/andrewdyer/slim3-session-middleware","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/andrewdyer%2Fslim3-session-middleware","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/andrewdyer%2Fslim3-session-middleware/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/andrewdyer%2Fslim3-session-middleware/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/andrewdyer%2Fslim3-session-middleware/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/andrewdyer","download_url":"https://codeload.github.com/andrewdyer/slim3-session-middleware/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/andrewdyer%2Fslim3-session-middleware/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":270746441,"owners_count":24638341,"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-08-16T02:00:11.002Z","response_time":91,"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":["middleware","php","session","session-management","session-middleware","slim","slim-framework","slim3"],"created_at":"2024-12-17T01:16:28.349Z","updated_at":"2025-08-16T17:32:03.695Z","avatar_url":"https://github.com/andrewdyer.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Slim3 Session Middleware\n\n[![Codacy Badge](https://api.codacy.com/project/badge/Grade/66698967b6ec44949eb30795f09a435e)](https://www.codacy.com/app/andrewdyer/slim3-session-middleware?utm_source=github.com\u0026amp;utm_medium=referral\u0026amp;utm_content=andrewdyer/slim3-session-middleware\u0026amp;utm_campaign=Badge_Grade)\n[![Latest Stable Version](https://poser.pugx.org/andrewdyer/slim3-session-middleware/version)](https://packagist.org/packages/andrewdyer/slim3-session-middleware)\n[![Latest Unstable Version](https://poser.pugx.org/andrewdyer/slim3-session-middleware/v/unstable)](//packagist.org/packages/andrewdyer/slim3-session-middleware)\n[![License](https://poser.pugx.org/andrewdyer/slim3-session-middleware/license)](https://packagist.org/packages/andrewdyer/slim3-session-middleware)\n[![Total Downloads](https://poser.pugx.org/andrewdyer/slim3-session-middleware/downloads)](https://packagist.org/packages/andrewdyer/slim3-session-middleware)\n[![Daily Downloads](https://poser.pugx.org/andrewdyer/slim3-session-middleware/d/daily)](https://packagist.org/packages/andrewdyer/slim3-session-middleware)\n[![Monthly Downloads](https://poser.pugx.org/andrewdyer/slim3-session-middleware/d/monthly)](https://packagist.org/packages/andrewdyer/slim3-session-middleware)\n[![composer.lock available](https://poser.pugx.org/andrewdyer/slim3-session-middleware/composerlock)](https://packagist.org/packages/andrewdyer/slim3-session-middleware)\n\nSimple session middleware for the Slim Framework. Also included is a useful helper class that allows PHP built-in session management.\n\n## License\n\nLicensed under MIT. Totally free for private or commercial projects.\n\n## Installation\n\n```bash\ncomposer require andrewdyer/slim3-session-middleware\n```\n\n## Usage\n\n```php\n\u003c?php\n\n$app = new \\Slim\\App();\n\n$app-\u003eadd(new \\Anddye\\Middleware\\SessionMiddleware([\n    'autorefresh'   =\u003e true,\n    'name'          =\u003e 'myapp_session',\n    'lifetime'      =\u003e '1 hour',\n]));\n\n$app-\u003eget('/', function (Request $request, Response $response) use ($container) {\n    if (!isset($container['session']['loggedIn'])) {\n        //...\n    }\n    ///..\n});\n\n$app-\u003erun();\n```\n\n### Supported Options\n\n| Option | Type | Default | Description |\n| --- | --- | --- | --- |\n| `autorefresh` | boolean | `false` | If you want session to be refresh when user activity is made (interaction with server). |\n| `domain` | tring | `null` | Cookie domain, for example 'www.php.net'. To make cookies visible on  all subdomains then the domain must be prefixed with a dot like '.php.net'. |\n| `handler` | mixed | `null` | Custom session handler class or object. Must implement `SessionHandlerInterface` as required by PHP. |\n| `httponly` | boolean | `false` | If set to true then PHP will attempt to send the httponly flag when setting the session cookie. |\n| `ini_settings` | array | `null` | Associative array of custom session configuration. |\n| `lifetime` | int or string | `\"20 minutes\"` | The lifetime of the session cookie. Can be set to any value which `strtotime` can parse. |\n| `name` | string | `\"session\"` | Name for the session cookie. Defaults to `session` instead of PHP's `PHPSESSID`. |\n| `path` |string | `\"/\"` | The path on the domain where the cookie will work. Use a single slash ('/') for all paths on the domain. |\n| `secure` | boolean | `false` | Cookies will only be sent over secure connections if true. |\n\n\n### Session Helper\n\nThe `\\Anddye\\Session\\Helper` class can be attached to your app container:\n\n```php\n$container = $app-\u003egetContainer();\n\n$container['session'] = function ($container) {\n    return new \\Anddye\\Session\\Helper();\n};\n```\n\nThe helper class can be used to check if a session variable exists in addition to setting, getting and deleting session variables.\n\n```php\n$app-\u003eget('/', function (Request $request, Response $response) use ($container) {\n    // Check if variable exists\n    $exists = $container['session']-\u003eexists('my_key');\n    $exists = isset($container['session']-\u003emy_key);\n    $exists = isset($container['session']['my_key']);\n\n    // Get variable value\n    $value = $container['session']-\u003eget('my_key', 'default');\n    $value = $container['session']-\u003emy_key;\n    $value = $container['session']['my_key'];\n\n    // Set variable value\n    $container['session']-\u003eset('my_key', 'my_value');\n    $container['session']-\u003emy_key = 'my_value';\n    $container['session']['my_key'] = 'my_value';\n\n    // Delete variable\n    $container['session']-\u003edelete('my_key');\n    unset($container['session']-\u003emy_key);\n    unset($container['session']['my_key']);\n});\n```\n\n## Support\n\nIf you are having general issues with this library, then please feel free to contact me on [Twitter](https://twitter.com/andyer92).\n\nIf you believe you have found an issue, please report it using the [issue tracker](https://github.com/andrewdyer/slim3-session-middleware/issues), or better yet, fork the repository and submit a pull request.\n\nIf you're using this package, I'd love to hear your thoughts!\n\n## Useful Links\n\n* [Slim Framework](https://www.slimframework.com)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fandrewdyer%2Fslim3-session-middleware","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fandrewdyer%2Fslim3-session-middleware","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fandrewdyer%2Fslim3-session-middleware/lists"}