PHPackages                             mohit-singh/db-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. mohit-singh/db-session

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

mohit-singh/db-session
======================

Store session in database in zend framework 2

5141[1 issues](https://github.com/Mohit-Singh/DbSession/issues)PHP

Since Jul 4Pushed 11y ago1 watchersCompare

[ Source](https://github.com/Mohit-Singh/DbSession)[ Packagist](https://packagist.org/packages/mohit-singh/db-session)[ RSS](/packages/mohit-singh-db-session/feed)WikiDiscussions master Synced 2d ago

READMEChangelogDependenciesVersions (1)Used By (0)

DbSession
=========

[](#dbsession)

Store Session in database in ZF2.

How To Use

This a very simple module to store all your session data in your database. for this create a table using the following schema.

```
CREATE TABLE `session` (
  `id` char(32) NOT NULL DEFAULT '',
  `name` varchar(255) NOT NULL,
  `modified` int(11) DEFAULT NULL,
  `lifetime` int(11) DEFAULT NULL,
  `data` text,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8
```

Now update the following database requirement in the config

```
    'db' => array(
        'driver'         => 'Pdo',
        'dsn'            => 'mysql:dbname=db_name;host=localhost',
        'username'       => 'user_name',
        'password'       => 'xxxxxxx',
        'host'           => 'localhost',
        'dbname'         => 'db_name',
        'driver_options' => array(
            PDO::MYSQL_ATTR_INIT_COMMAND => 'SET NAMES \'UTF8\''
        ),
    ),
    'service_manager' => array(
        'factories' => array(
            'Zend\Db\Adapter\Adapter'
                    => 'Zend\Db\Adapter\AdapterServiceFactory',
        ),
    ),
```

if you already define all these value in you global config please remove them.

now the module is ready to use. you can set the setting using following config values

```
'session' => array(
        'remember_me_seconds' => 2419200,
        'use_cookies'       => true,
        'cookie_httponly'   => true,
        'cookie_lifetime'   => 2419200,
        'gc_maxlifetime'    => 2419200,

    ),
```

Remember if you set "use\_cookies" to "false" then every time application will create a new session in database and your session data will removed.

###  Health Score

21

—

LowBetter than 19% of packages

Maintenance16

Infrequent updates — may be unmaintained

Popularity11

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity41

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.

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/3784341?v=4)[Mohit K.Singh](/maintainers/Mohit-Singh)[@Mohit-Singh](https://github.com/Mohit-Singh)

---

Top Contributors

[![Mohit-Singh](https://avatars.githubusercontent.com/u/3784341?v=4)](https://github.com/Mohit-Singh "Mohit-Singh (18 commits)")

### Embed Badge

![Health badge](/badges/mohit-singh-db-session/health.svg)

```
[![Health](https://phpackages.com/badges/mohit-singh-db-session/health.svg)](https://phpackages.com/packages/mohit-singh-db-session)
```

###  Alternatives

[doctrine/orm

Object-Relational-Mapper for PHP

10.2k285.3M6.2k](/packages/doctrine-orm)[jdorn/sql-formatter

a PHP SQL highlighting library

3.9k115.1M102](/packages/jdorn-sql-formatter)[illuminate/database

The Illuminate Database package.

2.8k52.4M9.4k](/packages/illuminate-database)[mongodb/mongodb

MongoDB driver library

1.6k64.0M546](/packages/mongodb-mongodb)[ramsey/uuid-doctrine

Use ramsey/uuid as a Doctrine field type.

90340.3M211](/packages/ramsey-uuid-doctrine)[reliese/laravel

Reliese Components for Laravel Framework code generation.

1.7k3.4M16](/packages/reliese-laravel)

PHPackages © 2026

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