PHPackages                             abbadon1334/atk4-session - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. abbadon1334/atk4-session

ActiveLibrary

abbadon1334/atk4-session
========================

php session using atk4 data handler

3.1.0(4y ago)17.4k[10 PRs](https://github.com/abbadon1334/atk4-session/pulls)MITPHPPHP &gt;=7.4 &lt;8.2

Since Aug 25Pushed 1mo ago1 watchersCompare

[ Source](https://github.com/abbadon1334/atk4-session)[ Packagist](https://packagist.org/packages/abbadon1334/atk4-session)[ RSS](/packages/abbadon1334-atk4-session/feed)WikiDiscussions master Synced 2mo ago

READMEChangelog (4)Dependencies (12)Versions (16)Used By (0)

ATK4 Session Handler
====================

[](#atk4-session-handler)

[![License](https://camo.githubusercontent.com/b6f0a06df183419f74f920ded5e0a642974ea971e8b9b876a7c35a8959d2bb5d/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f6c6963656e73652f61626261646f6e313333342f61746b342d73657373696f6e2e737667)](https://github.com/abbadon1334/atk4-session)[![Maintainability](https://camo.githubusercontent.com/d8211492f2c2e5e5eb719d77dd90bfdffbaabeaa4fde9a8657dc4c28c5f8d16b/68747470733a2f2f696d672e736869656c64732e696f2f636f6465636c696d6174652f6d61696e7461696e6162696c6974792f61626261646f6e313333342f61746b342d73657373696f6e2e737667)](https://codeclimate.com/github/abbadon1334/atk4-session)[![Maintainability](https://camo.githubusercontent.com/1126efe647e22393d727d6cb3442b1a612ac9c1db7a0ee62274dc5b0069a9238/68747470733a2f2f696d672e736869656c64732e696f2f636f6465636c696d6174652f6d61696e7461696e6162696c6974792d70657263656e746167652f61626261646f6e313333342f61746b342d73657373696f6e2e737667)](https://codeclimate.com/github/abbadon1334/atk4-session)[![Technical Debt](https://camo.githubusercontent.com/3a21a9bec4d27c6dbd6eaa1533394fb0cd93bf2c7b9ebb8d60816ecbde256445/68747470733a2f2f696d672e736869656c64732e696f2f636f6465636c696d6174652f746563682d646562742f61626261646f6e313333342f61746b342d73657373696f6e2e737667)](https://codeclimate.com/github/abbadon1334/atk4-session)[![Test Coverage](https://camo.githubusercontent.com/4bdaed1e69c145def5781b4bdfe7c8a17d6e7b2d011556754c2a8cec54a1795d/68747470733a2f2f696d672e736869656c64732e696f2f636f6465636f762f632f6769746875622f61626261646f6e313333342f61746b342d73657373696f6e2f6d61737465722e737667)](https://codecov.io/github/abbadon1334/atk4-session?branch=master)[![PHP version](https://camo.githubusercontent.com/d9f00270e5eaf1d931ced6494b8214efb21266faaec412857d081129d5c42304/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f7068702d762f61626261646f6e313333342f61746b342d73657373696f6e2e737667)](https://packagist.org/packages/abbadon1334/atk4-session)

Session handler for Atk4\\Data (@see )

### Install

[](#install)

`composer require abbadon1334/atk4-session`

### Initialize **without atk4\\ui**

[](#initialize-without-atk4ui)

```
// autoload
include '../vendor/autoload.php';

// create pesistence
$db = \Atk4\data\Persistence::connect('mysql://root:password@localhost/atk4');

// init session handler
new \Atk4\ATK4DBSession\SessionHandler($p, [/* session options */]);
```

*Create session table using atk4\\schema*

```
(new \Atk4\Data\Schema\Migrator(new \atk4\ATK4DBSession\SessionModel($p)))->create();
```

*OR*

*Create session table with SQL query*

```
CREATE TABLE `session` (
  `id` bigint() NOT NULL AUTO_INCREMENT,
  `session_id` varbinary(255) DEFAULT NULL,
  `data` blob,
  `created_on` datetime(6) NULL DEFAULT NULL,
  `updated_on` datetime(6) NULL DEFAULT NULL,
  PRIMARY KEY (`id`),
  KEY `session_id` (`session_id`)
) ENGINE=InnoDB;
```

Session GC
----------

[](#session-gc)

if you use InnoDB deletes are slow, so the best option for huge request application is to set a cronjob which run every 2 minutes, you can find an example in : `demos/example/cronjob.example.php`. When you instantiate the SessionHandler, if you use the crojob, set the gc\_probability option to 0 to disable automatic triggering of gc.

### Why i need to replace the default PHP Session Handler with this?

[](#why-i-need-to-replace-the-default-php-session-handler-with-this)

Because of file locking ( here a good article about the argument [link](https://ma.ttias.be/php-session-locking-prevent-sessions-blocking-in-requests/))

Every call that use sessions read a file and set a lock on it until release or output, to prevent race conditions.

It's clearly a shame to have file locking on things that are usually static, like nowadays sessions.

Using an alternative you'll have for sure race conditions, BUT what race condition can be if you, usually, have only an ID in $\_SESSION and that is nearly immutable from login to logout.

SessionHandler will substitute SessionHandler class in PHP and will store session data in database using atk4\\data instead of using files.

In atk4\\ui where async calls are massively used, this problem is much more evident.

You can add it without breaking your project, it already works, but is still in development and need a strong review for security issue.

###  Health Score

46

—

FairBetter than 93% of packages

Maintenance62

Regular maintenance activity

Popularity19

Limited adoption so far

Community11

Small or concentrated contributor base

Maturity78

Established project with proven stability

 Bus Factor1

Top contributor holds 94.4% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~296 days

Total

4

Last Release

1561d ago

Major Versions

v1.1 → 2.42021-08-04

2.4 → 3.1.02022-01-29

PHP version history (3 changes)v1.0PHP &gt;7.2.0

2.4PHP &gt;7.3.0

3.1.0PHP &gt;=7.4 &lt;8.2

### Community

Maintainers

![](https://www.gravatar.com/avatar/54f3bc6465a0f20b47cc7cd7bfe00f607bf80b9de41d5d35fa6740f4b6b3f6c9?d=identicon)[abbadon1334](/maintainers/abbadon1334)

---

Top Contributors

[![abbadon1334](https://avatars.githubusercontent.com/u/5801824?v=4)](https://github.com/abbadon1334 "abbadon1334 (68 commits)")[![renovate-bot](https://avatars.githubusercontent.com/u/25180681?v=4)](https://github.com/renovate-bot "renovate-bot (2 commits)")[![codacy-badger](https://avatars.githubusercontent.com/u/23704769?v=4)](https://github.com/codacy-badger "codacy-badger (1 commits)")[![mvorisek](https://avatars.githubusercontent.com/u/2228672?v=4)](https://github.com/mvorisek "mvorisek (1 commits)")

---

Tags

dataatk4session save handlerdsql

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan

Code StylePHP CS Fixer

Type Coverage Yes

### Embed Badge

![Health badge](/badges/abbadon1334-atk4-session/health.svg)

```
[![Health](https://phpackages.com/badges/abbadon1334-atk4-session/health.svg)](https://phpackages.com/packages/abbadon1334-atk4-session)
```

###  Alternatives

[fakerphp/faker

Faker is a PHP library that generates fake data for you.

3.9k358.5M3.5k](/packages/fakerphp-faker)[nelmio/alice

Expressive fixtures generator

2.5k43.4M133](/packages/nelmio-alice)[dflydev/dot-access-data

Given a deep data structure, access data by dot notation.

718359.1M86](/packages/dflydev-dot-access-data)[doctrine/mongodb-odm

PHP Doctrine MongoDB Object Document Mapper (ODM) provides transparent persistence for PHP objects to MongoDB.

1.1k23.3M301](/packages/doctrine-mongodb-odm)[theofidry/alice-data-fixtures

Nelmio alice extension to persist the loaded fixtures.

32528.5M70](/packages/theofidry-alice-data-fixtures)[atk4/login

Login and User module for Agile UI

2818.5k5](/packages/atk4-login)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
