PHPackages                             initphp/sessions - 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. [Database &amp; ORM](/categories/database)
4. /
5. initphp/sessions

ActiveLibrary[Database &amp; ORM](/categories/database)

initphp/sessions
================

InitPHP Sessions Manager

3.0(2y ago)0961MITPHPPHP &gt;=8.0

Since Jul 25Pushed 2y ago1 watchersCompare

[ Source](https://github.com/InitPHP/Sessions)[ Packagist](https://packagist.org/packages/initphp/sessions)[ RSS](/packages/initphp-sessions/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (4)DependenciesVersions (5)Used By (1)

InitPHP Session Manager
=======================

[](#initphp-session-manager)

Requirements
------------

[](#requirements)

- PHP 8.0 or later

**Note :** Adapters used may have different dependencies.

Installation
------------

[](#installation)

```
composer require initphp/sessions

```

Usage
-----

[](#usage)

```
require_once "vendor/autoload.php";
use InitPHP\Sessions\Session;

Session::createImmutable()
    ->start();

Session::set('username', 'admin')
        ->set('mail', 'admin@example.com');
/**
 * OR
 *
 * $_SESSION['username'] = 'admin';
 * $_SESSION['mail'] = 'admin@example.com';
 */

echo Session::get('username', 'Undefined');
/**
 * OR
 *
 * echo $_SESSION['username'] ?? 'Undefined';
 */
```

### Redis Adapter Usage

[](#redis-adapter-usage)

```
require_once "vendor/autoload.php";
use InitPHP\Sessions\Session;
use InitPHP\Sessions\Adapters\RedisAdapter;

$adapter = new RedisAdapter([
    'host'      => '127.0.0.1', // string
    'port'      => 6379, // int
    'timeout'   => 0, // int
    'password'  => null, // null or string
    'database'  => 0,
    'ttl'       => 86400,
    'prefix'    => 'sess'
]);

Session::createImmutable($adapter)
    ->start();
```

### PDO Adapter Usage

[](#pdo-adapter-usage)

```
require_once "vendor/autoload.php";
use InitPHP\Sessions\Session;
use InitPHP\Sessions\Adapters\PDOAdapter;

$pdo = new \PDO('mysql:host=localhost;dbname=test', 'root', '');

$adapter = new PDOAdapter(['pdo' => $pdo, 'table' => 'app_sessions']);

Session::createImmutable($adapter)
    ->start();
```

Example MySQL Table Create SQL :

```
CREATE TABLE `sessions` (
      `id` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
      `sess_timestamp` timestamp NULL DEFAULT NULL,
      `sess_ip_address` varchar(48) COLLATE utf8mb4_unicode_ci DEFAULT NULL
      `sess_data` text COLLATE utf8mb4_unicode_ci NOT NULL,
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
ALTER TABLE `sessions` ADD PRIMARY KEY (`id`);
```

### Memcache Adapter Usage

[](#memcache-adapter-usage)

```
require_once "vendor/autoload.php";
use InitPHP\Sessions\Session;
use InitPHP\Sessions\Adapters\MemCacheAdapter;

$adapter = new MemCacheAdapter([
        'host'          => '127.0.0.1', // string
        'port'          => 11211, // int
        'weight'        => 1, // int
        'raw'           => false, // boolean
        'prefix'        => null, // null or string
        'ttl'           => 86400, // int
]);

Session::createImmutable($adapter)
    ->start();
```

### Cookie Adapter Usage

[](#cookie-adapter-usage)

```
require_once "vendor/autoload.php";
use InitPHP\Sessions\Session;
use InitPHP\Sessions\Adapters\CookieAdapter;

$adapter = new CookieAdapter(['name' => 'sessDataCookieName', 'key' => 'topSecretAppKey', 'ttl' => 86400]);

Session::createImmutable($adapter)
    ->start();
```

### MongoDB Adapter Usage

[](#mongodb-adapter-usage)

```
require_once "vendor/autoload.php";
use InitPHP\Sessions\Session;
use InitPHP\Sessions\Adapters\MongoDBAdapter;

$adapter = new MongoDBAdapter(['dsn' => 'mongodb://127.0.0.1:27017', 'collation' => 'sessDbName.sessCollectionName']);

Session::createImmutable($adapter)
    ->start();
```

Credits
-------

[](#credits)

- [Muhammet ŞAFAK](https://github.com/muhammetsafak) &lt;&gt;

License
-------

[](#license)

Copyright © 2022 [MIT License](./LICENSE)

###  Health Score

26

—

LowBetter than 43% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity9

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity55

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% 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 ~169 days

Total

4

Last Release

885d ago

Major Versions

1.0 → 2.02022-12-09

2.0.1 → 3.02023-12-16

PHP version history (3 changes)1.0PHP &gt;=7.2

2.0PHP &gt;=7.4

3.0PHP &gt;=8.0

### Community

Maintainers

![](https://www.gravatar.com/avatar/4b6b34f3ac8938d8ee52ba3bd260680855dc5715c7b2929d9380de30d15a67dd?d=identicon)[muhammetsafak](/maintainers/muhammetsafak)

---

Top Contributors

[![muhammetsafak](https://avatars.githubusercontent.com/u/104234499?v=4)](https://github.com/muhammetsafak "muhammetsafak (5 commits)")

---

Tags

mysqlsqlitepostgresqlpostgressqlpdoredismemcachedmongodbsessioncookiesessionsmemcachesession handlerinitphp

### Embed Badge

![Health badge](/badges/initphp-sessions/health.svg)

```
[![Health](https://phpackages.com/badges/initphp-sessions/health.svg)](https://phpackages.com/packages/initphp-sessions)
```

###  Alternatives

[apix/cache

A thin PSR-6 cache wrapper with a generic interface to various caching backends emphasising cache taggging and indexing to Redis, Memcached, PDO/SQL, APC and other adapters.

114542.8k6](/packages/apix-cache)[doctrine/dbal

Powerful PHP database abstraction layer (DBAL) with many features for database schema introspection and management.

9.7k578.4M5.6k](/packages/doctrine-dbal)[aura/sqlquery

Object-oriented query builders for MySQL, Postgres, SQLite, and SQLServer; can be used with any database connection library.

4572.9M34](/packages/aura-sqlquery)[phpfastcache/phpfastcache

PHP Abstract Cache Class - Reduce your database call using cache system. Phpfastcache handles a lot of drivers such as Apc(u), Cassandra, CouchBase, Couchdb, Dynamodb, Firestore, Mongodb, Files, (P)redis, Leveldb, Memcache(d), Ravendb, Ssdb, Sqlite, Wincache, Xcache, Zend Data Cache.

2.4k5.0M130](/packages/phpfastcache-phpfastcache)[matthiasmullie/scrapbook

Scrapbook is a PHP cache library, with adapters for e.g. Memcached, Redis, Couchbase, APCu, SQL and additional capabilities (e.g. transactions, stampede protection) built on top.

3212.5M32](/packages/matthiasmullie-scrapbook)[aura/sql

A PDO extension that provides lazy connections, array quoting, query profiling, value binding, and convenience methods for common fetch styles. Because it extends PDO, existing code that uses PDO can use this without any changes to the existing code.

5632.5M43](/packages/aura-sql)

PHPackages © 2026

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