{"id":18550299,"url":"https://github.com/xp-forge/mongo-sessions","last_synced_at":"2026-02-09T12:03:26.260Z","repository":{"id":38022247,"uuid":"480905847","full_name":"xp-forge/mongo-sessions","owner":"xp-forge","description":"MongoDB Sessions","archived":false,"fork":false,"pushed_at":"2025-01-25T14:52:03.000Z","size":48,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-04-15T05:26:21.905Z","etag":null,"topics":["mongodb","php7","php8","session-storage","sessions","xp-framework"],"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/xp-forge.png","metadata":{"files":{"readme":"README.md","changelog":"ChangeLog.md","contributing":null,"funding":null,"license":null,"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":"2022-04-12T17:18:14.000Z","updated_at":"2025-01-25T14:49:36.000Z","dependencies_parsed_at":"2024-02-04T10:23:31.474Z","dependency_job_id":"dbaa2e2b-b233-438e-9420-7e529cbfeebb","html_url":"https://github.com/xp-forge/mongo-sessions","commit_stats":{"total_commits":21,"total_committers":1,"mean_commits":21.0,"dds":0.0,"last_synced_commit":"bbb70988b62b039ba96803c5fcb9cbcf230b6672"},"previous_names":[],"tags_count":12,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/xp-forge%2Fmongo-sessions","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/xp-forge%2Fmongo-sessions/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/xp-forge%2Fmongo-sessions/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/xp-forge%2Fmongo-sessions/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/xp-forge","download_url":"https://codeload.github.com/xp-forge/mongo-sessions/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254291831,"owners_count":22046415,"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":["mongodb","php7","php8","session-storage","sessions","xp-framework"],"created_at":"2024-11-06T21:04:09.054Z","updated_at":"2026-02-09T12:03:21.222Z","avatar_url":"https://github.com/xp-forge.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"MongoDB Sessions\n================\n\n[![Build status on GitHub](https://github.com/xp-forge/mongo-sessions/workflows/Tests/badge.svg)](https://github.com/xp-forge/mongo-sessions/actions)\n[![XP Framework Module](https://raw.githubusercontent.com/xp-framework/web/master/static/xp-framework-badge.png)](https://github.com/xp-framework/core)\n[![BSD Licence](https://raw.githubusercontent.com/xp-framework/web/master/static/licence-bsd.png)](https://github.com/xp-framework/core/blob/master/LICENCE.md)\n[![Requires PHP 7.4+](https://raw.githubusercontent.com/xp-framework/web/master/static/php-7_4plus.svg)](http://php.net/)\n[![Supports PHP 8.0+](https://raw.githubusercontent.com/xp-framework/web/master/static/php-8_0plus.svg)](http://php.net/)\n[![Latest Stable Version](https://poser.pugx.org/xp-forge/mongo-sessions/version.svg)](https://packagist.org/packages/xp-forge/mongo-sessions)\n\n[MongoDB](https://www.mongodb.com/)-based [sessions implementation](https://github.com/xp-forge/sessions).\n\nExample\n-------\n\n```php\nuse web\\session\\InMongoDB;\nuse com\\mongodb\\MongoConnection;\n\n$conn= new MongoConnection('mongodb://localhost');\n$sessions= new InMongoDB($conn-\u003ecollection('test', 'sessions'));\n``` \n\nSession expiry\n--------------\nBy default, cleaning up expired sessions is handled by the implementation. For a more performant version, use [TTL indexes](https://www.mongodb.com/docs/manual/core/index-ttl/) as follows.\n\n### Setup collection\nIssue the following in MongoDB shell:\n\n```javascript\ndb.sessions.createIndex({\"_created\": 1}, {expireAfterSeconds: 86400})\n```\n\n### Add TTL flag\nPass `InMongoDB::USING_TTL` as second parameter to the *InMongoDB* constructor:\n\n```php\n$sessions= new InMongoDB($conn-\u003ecollection('test', 'sessions'), InMongoDB::USING_TTL);\n```\n\nThis will use the *expireAfterSeconds* value as session duration.","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fxp-forge%2Fmongo-sessions","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fxp-forge%2Fmongo-sessions","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fxp-forge%2Fmongo-sessions/lists"}