PHPackages                             wikimedia/php-session-serializer - 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. [Utility &amp; Helpers](/categories/utility)
4. /
5. wikimedia/php-session-serializer

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

wikimedia/php-session-serializer
================================

Provides methods like PHP's session\_encode and session\_decode that don't mess with $\_SESSION

v3.0.2(9mo ago)211.3M↓29.5%72GPL-2.0-or-laterPHPPHP &gt;=7.4.0

Since Oct 14Pushed 1mo ago13 watchersCompare

[ Source](https://github.com/wikimedia/php-session-serializer)[ Packagist](https://packagist.org/packages/wikimedia/php-session-serializer)[ Docs](https://www.mediawiki.org/wiki/Php-session-serializer)[ RSS](/packages/wikimedia-php-session-serializer/feed)WikiDiscussions master Synced 1w ago

READMEChangelogDependencies (8)Versions (14)Used By (2)

[![Latest Stable Version](https://camo.githubusercontent.com/d59b74032e62395a470e94d681ae18cc22b0e374d0fb9df12ffdf71aea5ea34b/68747470733a2f2f706f7365722e707567782e6f72672f77696b696d656469612f7068702d73657373696f6e2d73657269616c697a65722f762f737461626c652e737667)](https://packagist.org/packages/wikimedia/php-session-serializer) [![License](https://camo.githubusercontent.com/15acf684b8ab5ad52130126bebf812631fb940b1f794d4656eac497bab502e06/68747470733a2f2f706f7365722e707567782e6f72672f77696b696d656469612f7068702d73657373696f6e2d73657269616c697a65722f6c6963656e73652e737667)](https://packagist.org/packages/wikimedia/php-session-serializer)

php-session-serializer
======================

[](#php-session-serializer)

php-session-serializer is a PHP library that provides methods that work like PHP's [session\_encode](https://php.net/manual/en/function.session-encode.php) and [session\_decode](https://php.net/manual/en/function.session-decode.php)functions, but don't mess with the `$_SESSION` superglobal.

It supports the `php`, `php_binary`, and `php_serialize` serialize handlers. `wddx` is not supported, since it is inferior to `php` and `php_binary`.

Usage
-----

[](#usage)

```
use Wikimedia\PhpSessionSerializer;

// (optional) Send logs to a PSR-3 logger
PhpSessionSerializer::setLogger( $logger )

// (optional) Ensure that session.serialize_handler is set to a usable value
PhpSessionSerializer::setSerializeHandler();

// Encode session data
$string = PhpSessionSerializer::encode( $array );

// Decode session data
$array = PhpSessionSerializer::decode( $string );
```

Running tests
-------------

[](#running-tests)

```
composer install --prefer-dist
composer test

```

History
-------

[](#history)

This library was created to support custom session handler [read](https://php.net/manual/en/sessionhandlerinterface.read.php) and [write](https://php.net/manual/en/sessionhandlerinterface.write.php) methods that are more useful than blindly storing the serialized data that PHP gives to custom handlers.

---

###  Health Score

59

—

FairBetter than 98% of packages

Maintenance77

Regular maintenance activity

Popularity49

Moderate usage in the ecosystem

Community29

Small or concentrated contributor base

Maturity70

Established project with proven stability

 Bus Factor3

3 contributors hold 50%+ of commits

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

Recently: every ~407 days

Total

13

Last Release

275d ago

Major Versions

v1.0.7 → v2.0.02021-03-21

v2.0.1 → v3.0.02024-08-13

PHP version history (4 changes)v1.0.0PHP &gt;=5.3.3

v1.0.5PHP &gt;=5.5.9

v2.0.0PHP &gt;=7.2.9

v3.0.0PHP &gt;=7.4.0

### Community

Maintainers

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

![](https://www.gravatar.com/avatar/716c86d71cbf921e7912a505f89d799de398fc0a3af0bd4c8862834b2d642bd7?d=identicon)[wikimedia](/maintainers/wikimedia)

---

Top Contributors

[![reedy](https://avatars.githubusercontent.com/u/67615?v=4)](https://github.com/reedy "reedy (12 commits)")[![jdforrester](https://avatars.githubusercontent.com/u/881572?v=4)](https://github.com/jdforrester "jdforrester (10 commits)")[![umherirrender](https://avatars.githubusercontent.com/u/1174884?v=4)](https://github.com/umherirrender "umherirrender (9 commits)")[![legoktm](https://avatars.githubusercontent.com/u/81392?v=4)](https://github.com/legoktm "legoktm (7 commits)")[![anomiex](https://avatars.githubusercontent.com/u/1030580?v=4)](https://github.com/anomiex "anomiex (5 commits)")[![bd808](https://avatars.githubusercontent.com/u/6469?v=4)](https://github.com/bd808 "bd808 (2 commits)")[![ricordisamoa](https://avatars.githubusercontent.com/u/4588496?v=4)](https://github.com/ricordisamoa "ricordisamoa (2 commits)")[![Krinkle](https://avatars.githubusercontent.com/u/156867?v=4)](https://github.com/Krinkle "Krinkle (2 commits)")[![MaxSem](https://avatars.githubusercontent.com/u/1260606?v=4)](https://github.com/MaxSem "MaxSem (1 commits)")[![fmalexander](https://avatars.githubusercontent.com/u/54070149?v=4)](https://github.com/fmalexander "fmalexander (1 commits)")[![DannyS712](https://avatars.githubusercontent.com/u/46829944?v=4)](https://github.com/DannyS712 "DannyS712 (1 commits)")[![Daimona](https://avatars.githubusercontent.com/u/38216014?v=4)](https://github.com/Daimona "Daimona (1 commits)")[![dringsim](https://avatars.githubusercontent.com/u/57343841?v=4)](https://github.com/dringsim "dringsim (1 commits)")

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/wikimedia-php-session-serializer/health.svg)

```
[![Health](https://phpackages.com/badges/wikimedia-php-session-serializer/health.svg)](https://phpackages.com/packages/wikimedia-php-session-serializer)
```

###  Alternatives

[symfony/lock

Creates and manages locks, a mechanism to provide exclusive access to a shared resource

515135.1M619](/packages/symfony-lock)[matomo/matomo

Matomo is the leading Free/Libre open analytics platform

21.6k38.2k](/packages/matomo-matomo)[phpro/soap-client

A general purpose SoapClient library

8955.9M52](/packages/phpro-soap-client)[ecotone/ecotone

Enterprise architecture layer for Laravel and Symfony — CQRS, Event Sourcing, Durable Workflows (Sagas, Orchestrators), Projections, and Outbox messaging via PHP attributes.

562565.8k41](/packages/ecotone-ecotone)[civicrm/civicrm-core

Open source constituent relationship management for non-profits, NGOs and advocacy organizations.

744284.3k34](/packages/civicrm-civicrm-core)[illuminate/broadcasting

The Illuminate Broadcasting package.

7126.9M199](/packages/illuminate-broadcasting)

PHPackages © 2026

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