{"id":14987429,"url":"https://github.com/michalsn/codeigniter-session-extended","last_synced_at":"2025-04-12T00:13:25.707Z","repository":{"id":183194019,"uuid":"656155757","full_name":"michalsn/codeigniter-session-extended","owner":"michalsn","description":"Manage database sessions in CodeIgniter 4","archived":false,"fork":false,"pushed_at":"2024-01-22T12:31:49.000Z","size":58,"stargazers_count":4,"open_issues_count":3,"forks_count":1,"subscribers_count":3,"default_branch":"develop","last_synced_at":"2025-04-12T00:13:18.167Z","etag":null,"topics":["codeigniter","codeigniter4","php","php8","session","session-management"],"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/michalsn.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}},"created_at":"2023-06-20T11:10:52.000Z","updated_at":"2024-05-26T15:51:12.000Z","dependencies_parsed_at":"2023-07-23T11:34:50.710Z","dependency_job_id":"5724e721-e247-4e06-818c-b6fd07df95a6","html_url":"https://github.com/michalsn/codeigniter-session-extended","commit_stats":{"total_commits":19,"total_committers":2,"mean_commits":9.5,"dds":"0.10526315789473684","last_synced_commit":"e257d4d73805c087770eb13f9db2721a8b447b4d"},"previous_names":["michalsn/codeigniter-session-extended"],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/michalsn%2Fcodeigniter-session-extended","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/michalsn%2Fcodeigniter-session-extended/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/michalsn%2Fcodeigniter-session-extended/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/michalsn%2Fcodeigniter-session-extended/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/michalsn","download_url":"https://codeload.github.com/michalsn/codeigniter-session-extended/tar.gz/refs/heads/develop","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248497820,"owners_count":21113984,"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":["codeigniter","codeigniter4","php","php8","session","session-management"],"created_at":"2024-09-24T14:14:36.129Z","updated_at":"2025-04-12T00:13:25.673Z","avatar_url":"https://github.com/michalsn.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# CodeIgniter Session Extended\n\nThis library gives users the ability to view their own active sessions and remove them from devices they no longer use.\n\nIt works only with database session handler.\n\n[![PHPUnit](https://github.com/michalsn/codeigniter-session-extended/actions/workflows/phpunit.yml/badge.svg)](https://github.com/michalsn/codeigniter-session-extended/actions/workflows/phpunit.yml)\n[![PHPStan](https://github.com/michalsn/codeigniter-session-extended/actions/workflows/phpstan.yml/badge.svg)](https://github.com/michalsn/codeigniter-session-extended/actions/workflows/phpstan.yml)\n[![Deptrac](https://github.com/michalsn/codeigniter-session-extended/actions/workflows/deptrac.yml/badge.svg)](https://github.com/michalsn/codeigniter-session-extended/actions/workflows/deptrac.yml)\n\n![PHP](https://img.shields.io/badge/PHP-%5E8.0-blue)\n![CodeIgniter](https://img.shields.io/badge/CodeIgniter-%5E4.3-blue)\n\n### Requirements\n\nThis library requires the application to comply with CodeIgniter 4 [authentication recommendations](https://codeigniter.com/user_guide/extending/authentication.html).\n\n### Installation\n\n#### Composer\n\n    composer require michalsn/codeigniter-session-extended\n\n#### Manually\n\nIn the example below we will assume, that files from this project will be located in `app/ThirdParty/session-extended` directory.\n\nDownload this project and then enable it by editing the `app/Config/Autoload.php` file and adding the `Michalsn\\CodeIgniterSessionExtended` namespace to the `$psr4` array, like in the below example:\n\n```php\n\u003c?php\n\nnamespace Config;\n\nuse CodeIgniter\\Config\\AutoloadConfig;\n\nclass Autoload extends AutoloadConfig\n{\n    // ...\n    public $psr4 = [\n        APP_NAMESPACE =\u003e APPPATH, // For custom app namespace\n        'Config'      =\u003e APPPATH . 'Config',\n        'Michalsn\\CodeIgniterSessionExtended' =\u003e APPPATH . 'ThirdParty/session-extended/src',\n    ];\n\n    // ...\n```\n\nNow, follow the instructions of [configuring session database handler](https://codeigniter.com/user_guide/libraries/sessions.html#configure-databasehandler) - with one distinction. You have to use `Michalsn\\SessionExtended\\DatabaseHandler` class instead of the core one.\n\n```php\n\u003c?php\n\nnamespace Config;\n\nuse CodeIgniter\\Config\\BaseConfig;\nuse Michalsn\\SessionExtended\\DatabaseHandler;\n\nclass Session extends BaseConfig\n{\n    // ...\n    public string $driver = DatabaseHandler::class;\n\n    // ...\n    public string $savePath = 'ci_sessions';\n\n    // ...\n}\n```\nThe last step will be to run a command that will add extra fields to the session table. To do so, run command:\n\n```cli\nphp spark se:install\n```\n\nThat's it. You're ready to go.\n\n### Example\n\n```php\n// app/Controllers/Home.php\n\u003c?php\n\nnamespace App\\Controllers;\n\nuse CodeIgniter\\Exceptions\\PageNotFoundException;\nuse Michalsn\\CodeIgniterSessionExtended\\SessionManager;\n\nclass Sessions extends BaseController\n{\n    public function index()\n    {\n        $sm = new SessionManager();\n\n        $data['sessions'] = $sm-\u003elist(user_id());\n\n        return view('sessions/index', $data);\n    }\n\n    public function delete()\n    {\n        if (! $this-\u003erequest-\u003eis('post')) {\n            throw new PageNotFoundException();\n        }\n\n        $rules = [\n            'id' =\u003e ['required', 'string', 'max_length[128]'],\n        ];\n\n        if (! $this-\u003evalidate($rules)) {\n            return redirect()-\u003eback();\n        }\n\n        $sm = new SessionManager();\n\n        if ($sm-\u003edelete($this-\u003erequest-\u003egetPost('id'), user_id())) {\n            return redirect()-\u003eback()-\u003ewith('success', 'Session was successfully deleted.');\n        }\n\n        return redirect()-\u003eback()-\u003ewith('error', 'Something went wrong.');\n    }\n}\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmichalsn%2Fcodeigniter-session-extended","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmichalsn%2Fcodeigniter-session-extended","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmichalsn%2Fcodeigniter-session-extended/lists"}