{"id":22747145,"url":"https://github.com/cs-eliseev/helpers-session","last_synced_at":"2025-10-26T15:10:12.333Z","repository":{"id":56959788,"uuid":"168752660","full_name":"cs-eliseev/helpers-session","owner":"cs-eliseev","description":"The helpers allows you to easily manage session data. START, SET, GET DELETE, HAS method session - all this is available in this library.","archived":false,"fork":false,"pushed_at":"2019-05-12T15:50:52.000Z","size":55,"stargazers_count":8,"open_issues_count":0,"forks_count":2,"subscribers_count":4,"default_branch":"master","last_synced_at":"2024-09-19T01:51:04.153Z","etag":null,"topics":["collection","collections","cse","framework","helper","helpers","library","php","session","sessions","tool","tools","utilities","utility","utils"],"latest_commit_sha":null,"homepage":null,"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/cs-eliseev.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2019-02-01T19:55:04.000Z","updated_at":"2023-06-14T15:24:38.000Z","dependencies_parsed_at":"2022-08-21T05:10:26.782Z","dependency_job_id":null,"html_url":"https://github.com/cs-eliseev/helpers-session","commit_stats":null,"previous_names":[],"tags_count":7,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cs-eliseev%2Fhelpers-session","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cs-eliseev%2Fhelpers-session/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cs-eliseev%2Fhelpers-session/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cs-eliseev%2Fhelpers-session/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/cs-eliseev","download_url":"https://codeload.github.com/cs-eliseev/helpers-session/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248872204,"owners_count":21175368,"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":["collection","collections","cse","framework","helper","helpers","library","php","session","sessions","tool","tools","utilities","utility","utils"],"created_at":"2024-12-11T03:13:22.380Z","updated_at":"2025-10-26T15:10:12.263Z","avatar_url":"https://github.com/cs-eliseev.png","language":"PHP","funding_links":["https://www.paypal.me/cseliseev/10usd"],"categories":[],"sub_categories":[],"readme":"English | [Русский](https://github.com/cs-eliseev/helpers-session/blob/master/README.ru_RU.md)\n\nSESSION CSE HELPERS\n=======\n\n[![Travis (.org)](https://img.shields.io/travis/cs-eliseev/helpers-session.svg?style=flat-square)](https://travis-ci.org/cs-eliseev/helpers-session)\n[![Codecov](https://img.shields.io/codecov/c/github/cs-eliseev/helpers-session.svg?style=flat-square)](https://codecov.io/gh/cs-eliseev/helpers-session)\n[![Scrutinizer code quality](https://img.shields.io/scrutinizer/g/cs-eliseev/helpers-session.svg?style=flat-square)](https://scrutinizer-ci.com/g/cs-eliseev/helpers-session/?branch=master)\n\n[![Packagist](https://img.shields.io/packagist/v/cse/helpers-session.svg?style=flat-square)](https://packagist.org/packages/cse/helpers-session)\n[![Minimum PHP Version](https://img.shields.io/badge/php-%3E%3D%207.1-8892BF.svg?style=flat-square)](https://packagist.org/packages/cse/helpers-session)\n[![Packagist](https://img.shields.io/packagist/l/cse/helpers-session.svg?style=flat-square)](https://github.com/cs-eliseev/helpers-session/blob/master/LICENSE.md)\n[![GitHub repo size](https://img.shields.io/github/repo-size/cs-eliseev/helpers-session.svg?style=flat-square)](https://github.com/cs-eliseev/helpers-session/archive/master.zip)\n\nThe helpers allows you to easily manage session data. START, SET, GET DELETE, HAS method session - all this is available in this library.\n\nProject repository: https://github.com/cs-eliseev/helpers-session\n\n**DEMO**\n```php\nSession::set(\n    'example_key',\n    Session::getNotEmpty('example_key', 'default_value')\n);\n\nif (is_int(Session::get('example_key'))) {\n    Session::remove('example_key');\n}\n\n$is_not_int = Session::has('example_key');\n```\n\n***\n\n\n## Introduction\n\n[CSE HELPERS](https://github.com/cs-eliseev/helpers/blob/master/README.md) is a collection of several libraries with simple functions written in PHP for people.\n\nDespite using PHP as the main programming language for the Internet, its functions are not enough. SESSION CSE HELPERS allows you to easy START, SET, GET DELETE session.\n\n[CSE HELPERS](https://github.com/cs-eliseev/helpers/blob/master/README.md) was created for the rapid development of web applications.\n\n**CSE Helpers project:**\n* [Array CSE helpers](https://github.com/cs-eliseev/helpers-arrays)\n* [Cookie CSE helpers](https://github.com/cs-eliseev/helpers-cookie)\n* [Date CSE helpers](https://github.com/cs-eliseev/helpers-date)\n* [Email CSE helpers](https://github.com/cs-eliseev/helpers-email)\n* [IP CSE helpers](https://github.com/cs-eliseev/helpers-ip)\n* [Json CSE helpers](https://github.com/cs-eliseev/helpers-json)\n* [Math Converter CSE helpers](https://github.com/cs-eliseev/helpers-math-converter)\n* [Phone CSE helpers](https://github.com/cs-eliseev/helpers-phone)\n* [Request CSE helpers](https://github.com/cs-eliseev/helpers-request)\n* [Session CSE helpers](https://github.com/cs-eliseev/helpers-session)\n* [Word CSE helpers](https://github.com/cs-eliseev/helpers-word)\n\nBelow you will find some information on how to init library and perform common commands.\n\n\n## Install\n\nYou can find the most recent version of this project [here](https://github.com/cs-eliseev/helpers-session).\n\n### Composer\n\nExecute the following command to get the latest version of the package:\n```bash\ncomposer require cse/helpers-session\n```\n\nOr file composer.json should include the following contents:\n```json\n{\n    \"require\": {\n        \"cse/helpers-session\": \"*\"\n    }\n}\n```\n\n### Git\n\nClone this repository locally:\n```bash\ngit clone https://github.com/cs-eliseev/helpers-session.git\n```\n\n### Download\n\n[Download the latest release here](https://github.com/cs-eliseev/helpers-session/archive/master.zip).\n\n## Usage\n\nThe class consists of static methods that are conveniently used in any project. See example [examples-session.php](https://github.com/cs-eliseev/helpers-session/blob/master/examples/examples-session.php).\n\n**START session**\n\nExample:\n```php\nSession::start();\n// true\n```\n\n**SET session**\n\nExample:\n```php\nSession::set('example_key', 'example_value');\n// ['example_key' =\u003e 'example_value']\n```\n\nUse multi key:\n```php\nSession::setMultiKey('cse');\nSession::set('example_key_2', 'example_value_2');\n// ['cse' =\u003e ['example_key_2' =\u003e 'example_value_2']]\n```\n\n**HAS session**\n\nExample:\n```php\nSession::set('example_key', 'example_value');\nSession::has('example_key');\n// true\n```\n\nUse multi key:\n```php\nSession::setMultiKey('cse');\nSession::has('example_key');\n// false\n```\n\n**GET session**\n\nExample:\n```php\nSession::set('example_key', 'example_value');\nSession::get('example_key');\n// example_value\n```\n\nUse multi key:\n```php\nSession::setMultiKey('cse');\nSession::set('example_key_2', 'example_value_2');\nSession::get('example_key_2');\n// example_value_2\n```\n\nSet default value is not exist session:\n```php\nCookie::get('example_key_3', 'example_default_value_3');\n// example_default_value_3\n```\n\n**GET NOT EMPTY session**\n\nExample:\n```php\nSession::set('example_key', 'example_value');\nSession::getNotEmpty('example_key', 'example_default_value');\n// example_value\n```\n\nUse multi key:\n```php\nSession::setMultiKey('cse');\nSession::set('example_key_2', 'example_value_2');\nSession::getNotEmpty('example_key_2');\n// example_value_2\n```\n\nSet default value is not exist session:\n```php\nCookie::getNotEmpty('example_key_3', 'example_default_value_3');\n// example_default_value_3\n```\n\nSet default value empty session data:\n```php\nSession::set('example_key_4', '');\nCookie::getNotEmpty('example_key_4', 'example_default_value_4');\n// example_default_value_4\n```\n\n**REMOVE session**\n\nExample:\n```php\nSession::set('example_key', 'example_value');\nSession::remove('example_key');\nSession::has('example_key');\n// false\n```\n\nUse multi key:\n```php\nSession::setMultiKey('cse');\nSession::set('example_key_2', 'example_value_2');\nSession::remove('example_key_2');\nSession::has('example_key_2');\n// false\n```\n\n**SET MULTI KEY session**\n\nExample:\n```php\nSession::set('example_key', 'example_value');\n// ['example_key' =\u003e 'example_value']\nSession::setMultiKey('cse');\nSession::set('example_key_2', 'example_value_2');\n/**\n* [\n*     'example_key' =\u003e 'example_value',\n*     'cse' =\u003e [\n*         'example_key_2' =\u003e 'example_value_2'\n*     ]\n* ]\n*/\nSession::set('example_key_3', 'example_value_3');\n/**\n* [\n*     'example_key' =\u003e 'example_value',\n*     'cse' =\u003e [\n*         'example_key_2' =\u003e 'example_value_2',\n*         'example_key_3' =\u003e 'example_value_3'\n*     ]\n* ]\n*/\nSession::setMultiKey();\nSession::set('example_key_4', 'example_value_4');\n/**\n* [\n*     'example_key' =\u003e 'example_value',\n*     'cse' =\u003e [\n*         'example_key_2' =\u003e 'example_value_2',\n*         'example_key_3' =\u003e 'example_value_3'\n*     ],\n*     'example_key_4' =\u003e 'example_value_4',\n*     'example' =\u003e [\n*         'example_key_5' =\u003e 'example_value_5'\n*     ],\n* ]\n*/\nSession::setMultiKey('example');\nSession::set('example_key_5', 'example_value_5');\n```\n\nGlobal use:\n```php\nclass DefaultSessionData\n{\n    public function setSessionData(): void\n    {\n        Session::setMultiKey();\n        Session::set('example_key_2', 'example_value_2');\n    }\n}\n\nclass CseSessionData\n{\n    public function setSessionData(): void\n    {\n        Session::setMultiKey('cse');\n        Session::set('example_key_1', 'example_value_1');\n    }\n}\n\nclass ExtendSessionData\n{\n    public function setSessionData(string $key, string $value): void\n    {\n        Session::set($key, $value);\n    }\n}\n\n$default = new DefaultSessionData();\n$cse = new CseSessionData();\n$extend = new ExtendSessionData();\n\n$extend-\u003esetSessionData('example_key_0', 'example_value_0');\n// ['example_key_0' =\u003e 'example_value_0']\n$cse-\u003esetSessionData();\n/**\n* [\n*     'example_key_0' =\u003e 'example_value_0',\n*     'cse' =\u003e [\n*         'example_key_1' =\u003e 'example_value_1'\n*     ]\n* ]\n*/\n$extend-\u003esetSessionData('example_key_1_1', 'example_value_1_1');\n/**\n* [\n*     'example_key_0' =\u003e 'example_value_0',\n*     'cse' =\u003e [\n*         'example_key_1' =\u003e 'example_value_1',\n*         'example_key_1_1' =\u003e 'example_value_1_1'\n*     ]\n* ]\n*/\n$default-\u003esetSessionData();\n/**\n* [\n*     'example_key_0' =\u003e 'example_value_0',\n*     'cse' =\u003e [\n*         'example_key_1' =\u003e 'example_value_1',\n*         'example_key_1_1' =\u003e 'example_value_1_1'\n*     ],\n*     'example_key_2' =\u003e 'example_value_2'\n* ]\n*/\n$extend-\u003esetSessionData('example_key_2_1', 'example_value_2_1');\n/**\n* [\n*     'example_key_0' =\u003e 'example_value_0',\n*     'cse' =\u003e [\n*         'example_key_1' =\u003e 'example_value_1',\n*         'example_key_1_1' =\u003e 'example_value_1_1'\n*     ],\n*     'example_key_2' =\u003e 'example_value_2',\n*     'example_key_2_1' =\u003e 'example_value_2_1'\n* ]\n*/\n```\n\n**Get ALL session data**\n\nExample:\n```php\nSession::set('example_key', 'example_value');\nSession::setMultiKey('cse');\nSession::set('example_key_2', 'example_value_2');\nSession::setMultiKey();\nSession::all();\n/**\n* [\n*     'example_key' =\u003e 'example_key',\n*     'cse' =\u003e [\n*         'example_key_2' =\u003e 'example_value_2'\n*     ]\n* ]\n*/\n```\n\nUse multi key:\n```php\nSession::set('example_key', 'example_value');\nSession::setMultiKey('cse');\nSession::set('example_key_2', 'example_value_2');\nSession::all();\n// ['example_key_2' =\u003e 'example_value_2']\n```\n\n**CLEAR session data**\n\nExample:\n```php\nSession::set('example_key', 'example_value');\nSession::setMultiKey('cse');\nSession::set('example_key_2', 'example_value_2');\nSession::setMultiKey();\nSession::claer();\n// []\n```\n\nUse multi key:\n```php\nSession::set('example_key', 'example_value');\nSession::setMultiKey('cse');\nSession::set('example_key_2', 'example_value_2');\nSession::claer();\n// ['example_key' =\u003e 'example_value']\n```\n\n**DESTROY session**\n\nExample:\n```php\nSession::start();\n// session_status() === PHP_SESSION_ACTIVE =\u003e true\nSession::destroy();\n// session_status() === PHP_SESSION_ACTIVE =\u003e false\n```\n\n**IS START session**\n\nExample:\n```php\nSession::start();\nSession::isStart();\n// true\nSession::destroy();\nSession::isStart();\n// false\n```\n\n\n## Testing \u0026 Code Coverage\n\nPHPUnit is used for unit testing. Unit tests ensure that class and methods does exactly what it is meant to do.\n\nGeneral PHPUnit documentation can be found at https://phpunit.de/documentation.html.\n\nTo run the PHPUnit unit tests, execute:\n```bash\nphpunit PATH/TO/PROJECT/tests/\n```\n\nIf you want code coverage reports, use the following:\n```bash\nphpunit --coverage-html ./report PATH/TO/PROJECT/tests/\n```\n\nUsed PHPUnit default config:\n```bash\nphpunit --configuration PATH/TO/PROJECT/phpunit.xml\n```\n\n\n## Donating\n\nYou can support this project [here](https://www.paypal.me/cseliseev/10usd). \nYou can also help out by contributing to the project, or reporting bugs. \nEven voicing your suggestions for features is great. Anything to help is much appreciated.\n\n\n## License\n\nThe SESSION CSE HELPERS is open-source PHP library licensed under the MIT license. Please see [License File](https://github.com/cs-eliseev/helpers-session/blob/master/LICENSE.md) for more information.\n\n***\n\n\u003e GitHub [@cs-eliseev](https://github.com/cs-eliseev)","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcs-eliseev%2Fhelpers-session","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcs-eliseev%2Fhelpers-session","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcs-eliseev%2Fhelpers-session/lists"}