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

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

romeoz/rock-session
===================

A simple Session library for PHP

0.12.0(10y ago)01.3k5MITPHPPHP &gt;=5.4.0

Since Mar 5Pushed 10y ago1 watchersCompare

[ Source](https://github.com/romeOz/rock-session)[ Packagist](https://packagist.org/packages/romeoz/rock-session)[ RSS](/packages/romeoz-rock-session/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (7)Dependencies (5)Versions (8)Used By (5)

Session library for PHP
=======================

[](#session-library-for-php)

[![Latest Stable Version](https://camo.githubusercontent.com/2e2bc65427f489a4464e664b8c78df0af5fef6127185c8db5f6a891915242cf7/68747470733a2f2f706f7365722e707567782e6f72672f726f6d654f7a2f726f636b2d73657373696f6e2f762f737461626c652e737667)](https://packagist.org/packages/romeOz/rock-session)[![Total Downloads](https://camo.githubusercontent.com/8e253cc34ff7d81a6bc3a723c8845e4939d6c1784672e3ee642d7077e1c5725d/68747470733a2f2f706f7365722e707567782e6f72672f726f6d654f7a2f726f636b2d73657373696f6e2f646f776e6c6f6164732e737667)](https://packagist.org/packages/romeOz/rock-session)[![Build Status](https://camo.githubusercontent.com/094b9621b03283b58319e1139870058498a5f98c7850aa89465d5c720cdaa9b1/68747470733a2f2f7472617669732d63692e6f72672f726f6d654f7a2f726f636b2d73657373696f6e2e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/romeOz/rock-session)[![HHVM Status](https://camo.githubusercontent.com/e2867a9582ec7a65159e1cbf992ef6e59b423621d8f9c8fa9b46cd08362b2f7b/687474703a2f2f6868766d2e683463632e64652f62616467652f726f6d656f7a2f726f636b2d73657373696f6e2e737667)](http://hhvm.h4cc.de/package/romeoz/rock-session)[![Coverage Status](https://camo.githubusercontent.com/b705c26f42b063087f1031a61456aedcd549b09c543254b21262526549042b85/68747470733a2f2f636f766572616c6c732e696f2f7265706f732f726f6d654f7a2f726f636b2d73657373696f6e2f62616467652e7376673f6272616e63683d6d6173746572)](https://coveralls.io/r/romeOz/rock-session?branch=master)[![License](https://camo.githubusercontent.com/d6d0e27bcbfdac7336fe0111b4baa5bf25cdfe143769c916277e10e399dba9cc/68747470733a2f2f706f7365722e707567782e6f72672f726f6d654f7a2f726f636b2d73657373696f6e2f6c6963656e73652e737667)](https://packagist.org/packages/romeOz/rock-session)

Handlers
--------

[](#handlers)

- File
- Memory
    - [Memcached](http://memcached.org/)
    - [Redis](http://redis.io)
    - [APC](http://pecl.php.net/package/APCu)
    - [Couchbase](http://www.couchbase.com)
- [MongoDB](https://www.mongodb.org/)
- RDBMS
    - [MySQL](http://www.mysql.com/)
    - [MariaDB](https://mariadb.com/)
    - [PostgreSQL](http://www.postgresql.org/)
    - etc...

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

[](#installation)

From the Command Line:

```
composer require romeoz/rock-session

```

or in your composer.json:

```
{
 "require": {
     "romeoz/rock-session": "*"
 }
}
```

Quick Start
-----------

[](#quick-start)

\####Session as key-value memory storage

```
$config = [
    'cache' => new \rock\cache\Memcached
];
$session = new \rock\session\MemorySession($config);
$session->add('name', 'Tom');

echo $session->get('name'); // result: Tom
```

\####Session as MongoDB storage

```
$config = [
    'connection' => new \rock\mongodb\Connection
];
$session = new \rock\session\MongoSession($config);
$session->add('name', 'Tom');

echo $session->get('name'); // result: Tom
```

Default is used the garbage collector (GC). You can use [TTL indexes](http://docs.mongodb.org/manual/tutorial/expire-data/).

```
$connection = new \rock\mongodb\Connection;

// Create TTL index
$connection
    ->getCollection('session')
    ->createIndex('expire', ['expireAfterSeconds' => 0]);

$config = [
    'connection' => $connection,
    'useGC' => false
];
$session = new \rock\session\MongoSession($config);
$session->add('name', 'Tom');

echo $session->get('name'); // result: Tom
```

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

[](#requirements)

- **PHP 5.4+**
- For `MemorySession` required [Rock Cache](https://github.com/romeOz/rock-cache): `composer require romeoz/rock-cache`
- For `MongoSession` required [Rock MongoDB](https://github.com/romeOz/rock-mongodb): `composer require romeoz/rock-mongodb`
- For `DbSession` required [Rock DB](https://github.com/romeOz/rock-db): `composer require romeoz/rock-db`

> All unbolded dependencies is optional.

License
-------

[](#license)

Session library is open-sourced software licensed under the [MIT license](http://opensource.org/licenses/MIT).

###  Health Score

27

—

LowBetter than 49% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity14

Limited adoption so far

Community13

Small or concentrated contributor base

Maturity53

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 ~41 days

Recently: every ~35 days

Total

7

Last Release

3844d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/23c5d84a59845d751cb69f5469986579b9312c54c898b366fefdc05baaa80a9c?d=identicon)[romeOz](/maintainers/romeOz)

---

Top Contributors

[![romeOz](https://avatars.githubusercontent.com/u/3135712?v=4)](https://github.com/romeOz "romeOz (47 commits)")

---

Tags

mysqlpostgresredismemorymemcachedmongodbsession

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/romeoz-rock-session/health.svg)

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

###  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)[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)[malkusch/lock

Mutex library for exclusive code execution.

9459.6M27](/packages/malkusch-lock)[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)[phpbu/phpbu

PHP Backup utility.

1.3k89.0k4](/packages/phpbu-phpbu)[arvenil/ninja-mutex

Simple to use mutex implementation that can use flock, memcache, memcached, mysql or redis for locking

1873.7M27](/packages/arvenil-ninja-mutex)

PHPackages © 2026

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