{"id":15026303,"url":"https://github.com/Alpine418/Session","last_synced_at":"2025-10-03T23:32:35.531Z","repository":{"id":57024952,"uuid":"278462238","full_name":"Alpine418/Session","owner":"Alpine418","description":"NOT MAINTAINED ANYMORE. Session service for Slim 4 and similar PSR-15 compliant frameworks and apps.","archived":true,"fork":false,"pushed_at":"2023-06-12T09:20:52.000Z","size":187,"stargazers_count":8,"open_issues_count":0,"forks_count":1,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-01-19T19:55:48.969Z","etag":null,"topics":["middleware","php73","psr-11","psr-15","session","session-service","slim","slim-framework","slim4"],"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/Alpine418.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}},"created_at":"2020-07-09T20:17:30.000Z","updated_at":"2023-06-12T09:21:19.000Z","dependencies_parsed_at":"2023-07-15T13:17:50.363Z","dependency_job_id":null,"html_url":"https://github.com/Alpine418/Session","commit_stats":null,"previous_names":["jnessier/session","alpine418/session"],"tags_count":9,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Alpine418%2FSession","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Alpine418%2FSession/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Alpine418%2FSession/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Alpine418%2FSession/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Alpine418","download_url":"https://codeload.github.com/Alpine418/Session/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":235204448,"owners_count":18952326,"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":["middleware","php73","psr-11","psr-15","session","session-service","slim","slim-framework","slim4"],"created_at":"2024-09-24T20:04:14.748Z","updated_at":"2025-10-03T23:32:30.208Z","avatar_url":"https://github.com/Alpine418.png","language":"PHP","funding_links":["https://www.paypal.me/JonathanNessier"],"categories":[],"sub_categories":[],"readme":"# This project is no longer maintained.\nPlease use other solutions for session handling on PHP.\n\n------------------------------------------------------------\n\n# Session\n[![Build Status](https://travis-ci.org/Neoflow/Session.svg?branch=master\u0026service=github)](https://travis-ci.org/Neoflow/Session)\n[![Coverage Status](https://coveralls.io/repos/github/Neoflow/Session/badge.svg?branch=master\u0026service=github)](https://coveralls.io/github/Neoflow/Session?branch=master)\n[![Latest Stable Version](https://poser.pugx.org/neoflow/session/v?service=github)](https://packagist.org/packages/neoflow/session)\n[![Total Downloads](https://poser.pugx.org/neoflow/session/downloads?service=github)](//packagist.org/packages/neoflow/session)\n[![License](https://poser.pugx.org/neoflow/session/license?service=github)](https://packagist.org/packages/neoflow/session)\n\nSession service for Slim 4 and similar [PSR-15](https://www.php-fig.org/psr/psr-15/) compliant frameworks and apps.\n\n## Table of Contents\n- [Requirement](#requirement)\n- [Installation](#installation)\n- [Configuration](#configuration)\n- [Usage](#usage)\n- [Flash messages](#flash-messages)\n- [Contributors](#contributors)\n- [History](#history)\n- [License](#license)\n\n## Requirement\n* PHP \u003e= 7.3\n\n## Installation\nYou have 2 options to install this library.\n\nVia composer...\n```bash\ncomposer require neoflow/session\n```\n...or manually download the latest release from [here](https://github.com/Neoflow/Session/releases/).\n\n## Configuration\nThe following instructions based on [Slim 4](http://www.slimframework.com), in combination with\n [PHP-DI](https://php-di.org), but should be adaptable for any PSR-11/PSR-15 compliant frameworks and libraries.\n\nAdd the service `Neoflow\\Session\\Session` and middleware `Neoflow\\Session\\Middleware\\SessionMiddleware`\n to the container definitions...\n```php\nuse Neoflow\\Session\\Session;\nuse Neoflow\\Session\\SessionInterface;\nuse Neoflow\\Session\\Middleware\\SessionMiddleware;\nuse Psr\\Container\\ContainerInterface;\n\nreturn [\n    // ...\n    SessionInterface::class =\u003e function () {\n        return new Session([ // Default session options\n            'name' =\u003e 'sid',\n            'autoRefresh' =\u003e true,\n            'cookie' =\u003e [\n                'lifetime' =\u003e 3600,\n                'path' =\u003e '/',\n                'domain' =\u003e null,\n                'secure' =\u003e false,\n                'httponly' =\u003e true,\n                'samesite' =\u003e 'Lax'\n            ],\n            'iniSettings' =\u003e []\n        ]);\n    },\n    SessionMiddleware::class =\u003e function (ContainerInterface $container) {\n        $session = $container-\u003eget(SessionInterface::class);\n        return new SessionMiddleware($session);\n    },\n    // ...\n];\n```\n...and register the middleware, to autostart the session when it got dispatched. \n```php\nuse Neoflow\\Session\\Middleware\\SessionMiddleware;\n\n$app-\u003eadd(SessionMiddleware::class);\n```\n\nThe service `Neoflow\\Session\\Session` supports the following options:\n\n| Key | Type | Description | Default |\n|---|---|---|---|\n| `name` | string | Name of the session cookie. | `\"sid\"` |\n| `autoRefresh` | bool | Refresh of session lifetime after each request. | `true` |\n| `cookie['lifetime']` | int | Lifetime in seconds of the session cookie in seconds | `3600` |\n| `cookie['path']` | string | Path to set in the session cookie | `\"/\"` |\n| `cookie['domain']` | string/null | Domain to set in the session cookie | `null` |\n| `cookie['secure']` | bool | Set `true` to sent session cookie only  over secure connections | `false` |\n| `cookie['httponly']` | bool | Set `false` to make session cookie accessible for scripting languages | `true` |\n| `cookie['samesite']` | string | Set `\"Strict\"` to prevent the session cookie be sent along with cross-site requests | `\"Lax\"` |\n| `iniSettings[]` | array | [PHP session settings](https://www.php.net/manual/en/session.configuration.php), without `session.` | `[]` |\n\nWhen your DI container supports inflectors (e.g. [league/container](https://container.thephpleague.com/3.x/inflectors/)),\n you can optionally register `Neoflow/Session/SessionAwareInterface` as inflector to your container definition.\n\nAdditionally, you can also use `Neoflow/Session/SessionAwareTrait` as a shorthand implementation of\n `Neoflow/Session/SessionAwareInterface`.\n\n## Usage\nExamples how to handle the session:\n```php\n// Set session name.\n$name = 'sid'; // Session name\n$session = $session-\u003esetName($name);\n\n// Set session cookie.\n$session = $session-\u003esetCookie([\n    // Cookie options\n]);\n\n// Start session.\n$started = $session-\u003estart();\n\n// Get session status.\n$status = $session-\u003egetStatus();\n\n// Check whether session is started.\n$isStarted = $session-\u003eisStarted();\n\n// Generate new session id.\n$id = $session-\u003egenerateId();\n\n// Get session cookie.\n$cookie = $session-\u003egetCookie();\n\n// Get session id.\n$id = $session-\u003egetId();\n\n// Get session name.\n$name = $session-\u003egetName();\n\n// Destroy session.\n$destroyed = $session-\u003edestroy();\n```\n\nExamples how to access and manage the values of the session:\n```php\n// Get session value by key.\n$default = null; // Default value, when key doesn't exists\n$value = $session-\u003egetValue('key', $default);\n\n// Set session value by key.\n$overwrite = true; // Set FALSE to prevent overwrite existing value\n$session = $session-\u003esetValue('key', 'value', $overwrite);\n\n// Check whether session value exists by key.\n$valueExists = $session-\u003ehasValue('key');\n   \n// Delete session value by key.\n$session-\u003edeleteValue('key');\n\n// Count number of session values.\n$numberOfValues = $session-\u003ecountValues();\n\n// Get session values.\n$values = $session-\u003egetValues();\n\n// Clear session values.\n$session = $session-\u003eclearValues();\n\n// Replace session values by key. Existing values with similar keys will be overwritten.\n$recursive = true; // Set TRUE to enable recursive replacement\n$session = $session-\u003ereplaceValues([\n    // Array with key/value pairs\n], $recursive);\n\n// Set session values. Existing values will be overwritten.\n$session = $session-\u003esetValues([\n    // Array with key/value pairs\n]);\n```\n\n## Flash messages\nThe first version of this library had built-in support for flash messages.\nBut to comply with the design principle of separation of concerns, the code of the flash messages was move into a\n standalone library, called [Neoflow\\FlashMessages](https://github.com/Neoflow/FlashMessages).\n\nIf you need support for flash messages, you can easily combine both libraries as composer packages. \nThe integration and usage of [Neoflow\\FlashMessages](https://github.com/Neoflow/FlashMessages) is very similar to the\n current library. \n\n## Contributors\n* Jonathan Nessier, [Neoflow](https://www.neoflow.ch)\n\nIf you would like to see this library develop further, or if you want to support me or show me your appreciation, please\n donate any amount through PayPal. Thank you! :beers:\n \n[![Donate](https://img.shields.io/badge/Donate-paypal-blue)](https://www.paypal.me/JonathanNessier)\n\n## License\nLicensed under [MIT](LICENSE). \n\n*Made in Switzerland with :cheese: and :heart:*\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FAlpine418%2FSession","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FAlpine418%2FSession","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FAlpine418%2FSession/lists"}