{"id":28955811,"url":"https://github.com/kodedphp/session","last_synced_at":"2026-03-06T21:32:26.901Z","repository":{"id":57007927,"uuid":"149984109","full_name":"kodedphp/session","owner":"kodedphp","description":"A session library with custom handlers and php.ini support.","archived":false,"fork":false,"pushed_at":"2025-06-23T15:24:26.000Z","size":105,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-08-30T20:29:06.888Z","etag":null,"topics":["memcached","middleware","php-sessions","redis","session","session-handler"],"latest_commit_sha":null,"homepage":null,"language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"bsd-3-clause","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/kodedphp.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,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2018-09-23T12:51:52.000Z","updated_at":"2021-05-06T06:33:52.000Z","dependencies_parsed_at":"2025-06-23T20:10:12.621Z","dependency_job_id":"27a54610-17e2-4aae-97e4-8f84d164a146","html_url":"https://github.com/kodedphp/session","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"purl":"pkg:github/kodedphp/session","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kodedphp%2Fsession","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kodedphp%2Fsession/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kodedphp%2Fsession/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kodedphp%2Fsession/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/kodedphp","download_url":"https://codeload.github.com/kodedphp/session/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kodedphp%2Fsession/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":30198661,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-03-06T19:07:06.838Z","status":"ssl_error","status_checked_at":"2026-03-06T18:57:34.882Z","response_time":250,"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":["memcached","middleware","php-sessions","redis","session","session-handler"],"created_at":"2025-06-23T20:10:09.393Z","updated_at":"2026-03-06T21:32:26.853Z","avatar_url":"https://github.com/kodedphp.png","language":"PHP","readme":"Koded Session\n=============\n\n[![Latest Stable Version](https://img.shields.io/packagist/v/koded/session.svg)](https://packagist.org/packages/koded/session)\n[![Build Status](https://travis-ci.org/kodedphp/session.svg?branch=master)](https://travis-ci.org/kodedphp/session)\n[![Code Coverage](https://scrutinizer-ci.com/g/kodedphp/session/badges/coverage.png?b=master)](https://scrutinizer-ci.com/g/kodedphp/session/?branch=master)\n[![Scrutinizer Code Quality](https://scrutinizer-ci.com/g/kodedphp/session/badges/quality-score.png?b=master)](https://scrutinizer-ci.com/g/kodedphp/container/?branch=master)\n[![Minimum PHP Version](https://img.shields.io/badge/php-%3E%3D%207.3-8892BF.svg)](https://php.net/)\n[![Software license](https://img.shields.io/badge/License-BSD%203--Clause-blue.svg)](LICENSE)\n\n\nThe library relies on the `php.ini` settings.\nEvery session ini directive can be reset with the\n`Koded\\Session\\SessionConfiguration` object.\n\nRefer to php.ini session directives:\nhttp://php.net/manual/en/session.security.ini.php\n\n\nUsage\n-----\n\nThe session is started automatically by using one of the 2 methods:\n\n### app configuration\n```php\n[\n    'session' =\u003e [\n        // your ini \"session.\" overwrites, without \"session.\" prefix\n    ]\n]\n```\n\n### or using a `SessionMiddleware`\ninclude this middleware class in your middleware stack\n\n```php\n// your middleware stack\n$middleware = [\n    SessionMiddleware::class\n];\n```\n\nSession class and function\n--------------------------\n\n```php\nsession()-\u003eget('key');\nsession()-\u003eset('key', 'value');\n// etc.\n```\n\nThe session class can be instantiated and used, but the function `session()`\nis recommended instead an instance of `Session` class.\n\n\nHandlers Configuration\n======================\n\nThe bare minimum is to define the handler you want to use for the session:\n\n```php\n// in your configuration file\n\nreturn [\n    'session' =\u003e [\n        'save_handler' =\u003e 'redis | memcache'\n    ]\n]\n```\n\nIf you do not choose one of the Redis or Memcached, it defaults to `files`\nhandler which is the PHP's default session mechanism.\n\nHowever, the `files` handler might not be desirable if your application\nruns in Docker, Kubernetes, distributed environment, etc.\n\n\u003e The best choice for PHP sessions is Redis in almost all situations.\n\nWARNING: Memcached may drop the session data, because it's nature. Use it with caution!\n\nRedis handler\n-------------\n\n```php\n[\n    'session' =\u003e [\n        'save_handler' =\u003e 'redis'\n        \n        // OPTIONAL, these are the defaults\n        'host' =\u003e 'localhost',\n        'port' =\u003e 6379,\n        'timeout' =\u003e 0.0,\n        'retry' =\u003e 0,\n        'db' =\u003e 0,\n        \n        'prefix' =\u003e 'sess:',\n        'serializer' =\u003e 'php', // or \"json\"\n        'binary' =\u003e false,     // TRUE for igbinary\n    ]\n]\n```\n\nA typical Redis settings:\n  - 1 server\n  - application + redis on the same machine\n  - Redis (127.0.0.1:6379)\n  - no auth (Redis is not available from outside)\n\n```php\n[\n    'session' =\u003e [\n        'save_handler' =\u003e 'redis',\n        'name'         =\u003e 'session-name',\n        'prefix'       =\u003e 'sess:',\n\n        // isolate the session data in other db\n        'db'           =\u003e 1\n    ]\n]\n```\n\nTo support huge volumes you need a good sysadmin skills and wast knowledge\nto set the Redis server(s).\n\n\nMemcached handler\n-----------------\n\n```php\n[\n    'session' =\u003e [\n        'save_handler' =\u003e 'memcached',\n        \n        // OPTIONAL: defaults to ['127.0.0.1', 11211]\n        // If you have multiple memcached servers\n        'servers' =\u003e [\n            ['127.0.0.1', 11211],\n            ['127.0.0.1', 11212],\n            ['127.0.0.2']\n            ...\n        ],\n        \n        // OPTIONAL: the options are not mandatory\n        'options' =\u003e [\n            ...\n        ]\n    ]\n]\n```\n\nA typical Memcached settings:\n  - 1 server\n  - application + memcached on the same machine\n  - Memcached (127.0.0.1:11211)\n\n```php\n[\n    'session' =\u003e [\n        'save_handler' =\u003e 'memcached',\n        'name'         =\u003e 'session-name',\n        'prefix'       =\u003e 'sess.'\n    ]\n]\n```\n\nTo support huge amount of users you need a decent amounts of RAM\non your servers. But Memcached is a master technology for this, so you should be fine.\n\n\nFiles handler\n-------------\n\nThis one is not recommended for any serious business.\nIt's fine only for small projects.\n\nAll session directives are copied from `php.ini`.\n\n```php\n[\n    'session' =\u003e [\n        // OPTIONAL: defaults to \"session_save_path()\"\n        // the path where to store the session data\n        'save_path' =\u003e '/var/www/sessions',\n        'serialize_handler' =\u003e 'php'\n    ]\n]\n```\n\nA typical native PHP session settings:\n```php\n[\n    'session' =\u003e [\n        // really nothing,\n        // skip this section in your configuration\n    ]\n]\n\n```\n\nYou cannot use this handler if you've scaled your application,\nbecause the session data will most likely be handled randomly \non a different instance for every HTTP request.\n\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkodedphp%2Fsession","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fkodedphp%2Fsession","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkodedphp%2Fsession/lists"}