Session serializing!

Clone this repo:
  1. b1dcb18 Update copy of GPL license and licensing headers in files by James D. Forrester · 2 weeks ago master
  2. 61a1b91 build: Update phpunit/phpunit to 10.5.58 by Umherirrender · 10 weeks ago
  3. 0b72dd7 build: Updating ockcyp/covers-validator to 1.7.0 by libraryupgrader · 2 months ago
  4. b14ae6e build: Updating mediawiki/mediawiki-codesniffer to 48.0.0 by libraryupgrader · 3 months ago v3.0.2
  5. 908b3f8 build: Updating mediawiki/mediawiki-phan-config to 0.17.0 by libraryupgrader · 4 months ago

Latest Stable Version License

php-session-serializer

php-session-serializer is a PHP library that provides methods that work like PHP's session_encode and session_decode 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

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

composer install --prefer-dist
composer test

History

This library was created to support custom session handler read and write methods that are more useful than blindly storing the serialized data that PHP gives to custom handlers.