PHPackages                             locosoftworks/zf2-cookie-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. locosoftworks/zf2-cookie-session

ActiveLibrary

locosoftworks/zf2-cookie-session
================================

Session save handler used to store the session in a cookie

19PHP

Since Jul 10Pushed 11y ago1 watchersCompare

[ Source](https://github.com/moranjk/ZF2-PHPCookieSession)[ Packagist](https://packagist.org/packages/locosoftworks/zf2-cookie-session)[ RSS](/packages/locosoftworks-zf2-cookie-session/feed)WikiDiscussions master Synced today

READMEChangelogDependenciesVersions (1)Used By (0)

Cookie Session Handler
======================

[](#cookie-session-handler)

### Requires

[](#requires)

- PHP &gt;= 5.3
- [PHPCookieSession](https://github.com/moranjk/PHPCookieSession)

### Composer Install

[](#composer-install)

Add the following to `composer.json` and execute `composer update`

```
"minimum-stability": "dev",
"require": {
    "locosoftworks/zf2-cookie-session": "dev-master"
}

```

### Usage

[](#usage)

To use the session handler in ZF2, you will need to ensure the session is written before any output is returned. This can be achieved by adding a listenter to the `SendResponseEvent::EVENT_SEND_RESPONSE` event, or use the provided SessionManager. This can be done in your `application.config.php`

```
'service_manager' => array(
	'invokables' => array(
	    'SessionManager' => 'Loco\Session\SessionManager',
	),
)

```

To encrypt the client side session, you will need to provide your own encryption method that implements `\Loco\Crypt\CipherInterface`. For more information regarding how to use the provided encryption method, please see the [ZF2 Documentation on Block Cipher](http://framework.zend.com/manual/2.0/en/modules/zend.crypt.block-cipher.html)

```
$cipher = new \Loco\Crypt\BlockCipher(new \Zend\Crypt\Symmetric\Mcrypt(array('algo' => 'aes')));
$cipher->setKey('This is my application secret key');

```

This will need to be high enough in your stack that it is called before anything else attempts to start the session. The location of this code could very, but placing it at the top of your `onBootstrap` method sholud suffice.

```
// assuming $sm is your ServiceManager and SessionManager is a Loco\Session\SessionManager
$sessionManager = $sm->get('SessionManager');

// ClientSessionAdapter is a ZF2 wrapper to the ClientSession
$sessionAdapter = new \Loco\Session\SaveHandler\ClientSessionAdapter();

// set the cipher
$sessionAdapter->setCipher($cipher);

$sessionManager->setSaveHandler($sessionAdapter);

// the SessionManager NEEDS the EventManager to set up the necessary listeners
$sessionManager->setEventManager($eventManager);

$sessionManager->start();

```

###  Health Score

20

—

LowBetter than 14% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity6

Limited adoption so far

Community7

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://www.gravatar.com/avatar/bd9d6d1eebbd034a31da56e1e253bc6fba8fb00b4c8516efae5c2dea5ac0478e?d=identicon)[moranjk](/maintainers/moranjk)

---

Top Contributors

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

### Embed Badge

![Health badge](/badges/locosoftworks-zf2-cookie-session/health.svg)

```
[![Health](https://phpackages.com/badges/locosoftworks-zf2-cookie-session/health.svg)](https://phpackages.com/packages/locosoftworks-zf2-cookie-session)
```

PHPackages © 2026

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