PHPackages                             ronanchilvers/silex-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. [Framework](/categories/framework)
4. /
5. ronanchilvers/silex-sessions

ActiveLibrary[Framework](/categories/framework)

ronanchilvers/silex-sessions
============================

Client side encrypted sessions for Silex

v1.1(7y ago)0936MITPHP

Since Jan 23Pushed 7y ago1 watchersCompare

[ Source](https://github.com/ronanchilvers/silex-sessions)[ Packagist](https://packagist.org/packages/ronanchilvers/silex-sessions)[ RSS](/packages/ronanchilvers-silex-sessions/feed)WikiDiscussions master Synced 2w ago

READMEChangelog (2)Dependencies (1)Versions (3)Used By (0)

silex-sessions
==============

[](#silex-sessions)

[![Beta Status](https://camo.githubusercontent.com/e9307322b2a63c482bb1b4b8f577bf0b438b115b824e3fff7389d14b1ce052bc/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f7374617475732d626574612d626c75652e7376673f7374796c653d666c61742d737175617265)](https://camo.githubusercontent.com/e9307322b2a63c482bb1b4b8f577bf0b438b115b824e3fff7389d14b1ce052bc/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f7374617475732d626574612d626c75652e7376673f7374796c653d666c61742d737175617265)

[cookie icon by Rashida Luqman Kheriwala from the Noun Project](https://thenounproject.com/search/?q=cookie&i=119497)

This package provides client side, cookie based sessions for Silex. It is a standalone implementation and does not use Symfony's session mechanism. Session data is stored in a cookie allowing excellent horizontal scalability. The serialized data is encryption using [defuse/php-encryption](https://github.com/defuse/php-encryption) to ensure it is safe in the wild.

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

[](#installation)

Installation is easy via composer:

```
composer require ronanchilvers/silex-sessions
```

Configuration
-------------

[](#configuration)

Firstly you need to add the service provider. There are various configuration options (detailed below) but you must at least provide an encryption key. See the [key generation section below](#encryption-key-generation) for details on creating a secure key.

```
$app->register(new Ronanchilvers\Silex\Sessions\SessionProvider(), [
    'encryption.key' => $secureKey
]);
```

### Configuration options

[](#configuration-options)

There are various configuration options you can use, mostly to tweak the cookie storage the session uses. These are:

- cookie.name - The name of the session cookie
- cookie.expire - Expiry time for the cookie - by default when the browser closes
- cookie.path - The cookie path - '/' by default
- cookie.domain - The cookie domain - empty by default
- cookie.secure - Whether the session cookie should only be valid for HTTPS connections
- cookie.http.only - Whether the cookie should only be available via HTTP
- encryption.key - The secure encryption key to use for encrypting and decrypting the cookie payload

Usage
-----

[](#usage)

`SessionProvider` registers a couple of services on the container:

- A `session` service, the standard session interface. This service has the usual `get()`, `set()`, `addFlash()` and `getFlash()` methods available.
- If you're using [`knplabs/console-service-provider`](https://github.com/KnpLabs/ConsoleServiceProvider) you'll also get a `session:key:generate` command to use for key generation. **NB:** Make sure that you register the console provider *before* the session provider.

```
// Set session variables
$app['session']->set('name', 'Fred Bloggs');
$app['session']->set('stuff', ['data' => 123]);
$app['session']->addFlash('notice', 'Yeehaa!');

// Get them out again
$name = $app['session']->get('name');
// With a default
$stuff = $app['session']->get('stuff', []);

// Get the flashes for a particular type
foreach ($app['session']->getFlashes('notice') as $message) {
    echo "Notice : {$message}";
}
```

Symfony Web Profiler Support
----------------------------

[](#symfony-web-profiler-support)

A data collector for the Symfony Web Profiler is included. To use it you need to first add the `silex/web-profiler` package to your project. Then enable the web profiler providers like so:

```
$app->register(new Silex\Provider\WebProfilerServiceProvider(), [
    'profiler.cache_dir' => 'a directory somewhere',
]);
$app->register(new Ronanchilvers\Silex\Sessions\SessionWebProfilerProvider());
```

You should then start seeing a new button on the profiler toolbar and a new panel showing the session contents.

Encryption Key Generation
-------------------------

[](#encryption-key-generation)

Generating a decently secure encryption key is important to maintain the security of the session data. This package provides a [Symfony console](https://github.com/symfony/console) command to generate and output an ASCII safe key which you can store in a config file. The console command is added automatically if you're using [knplabs/console-service-provider](https://github.com/KnpLabs/ConsoleServiceProvider).

```
$ php bin/console session:key:generate
Generating new random encryption key
Key : aaf2234228005e7766c2e5075d9d229a4ff9fd0788a8c1d4dde08b1aa3a3d0e413c7694174201e20989fcb9db8238a8b6bdb1277f3d0e413c766c2e5075d9d2197d4d5b
```

###  Health Score

29

—

LowBetter than 57% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity14

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity64

Established project with proven stability

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

Total

2

Last Release

2690d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/f6d7178329cb95270cfb9c807c3d2a6485d0f856c3d81cfe432e469e5f958748?d=identicon)[ronanchilvers](/maintainers/ronanchilvers)

---

Top Contributors

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

### Embed Badge

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

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

###  Alternatives

[pimcore/pimcore

Content &amp; Product Management Framework (CMS/PIM/E-Commerce)

3.8k3.8M464](/packages/pimcore-pimcore)[prestashop/prestashop

PrestaShop is an Open Source e-commerce platform, committed to providing the best shopping cart experience for both merchants and customers.

9.1k16.8k](/packages/prestashop-prestashop)[spiral/framework

Spiral, High-Performance PHP/Go Framework

2.1k2.1M63](/packages/spiral-framework)[open-dxp/opendxp

Content &amp; Product Management Framework (CMS/PIM)

9417.2k55](/packages/open-dxp-opendxp)[jelix/jelix

Jelix PHP framework

84109.7k5](/packages/jelix-jelix)[shopsys/framework

Core of Shopsys Platform - open source framework for building large, scalable, fast-growing e-commerce projects based on Symfony

25220.6k36](/packages/shopsys-framework)

PHPackages © 2026

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