wikimedia / php-session-serializer
Provides methods like PHP's session_encode and session_decode that don't mess with $_SESSION
v3.0.0
2024-08-13 06:23 UTC
Requires
- php: >=7.4.0
- psr/log: ^1.0
Requires (Dev)
- mediawiki/mediawiki-codesniffer: 44.0.0
- mediawiki/mediawiki-phan-config: 0.14.0
- mediawiki/minus-x: 1.1.3
- ockcyp/covers-validator: 1.6.0
- php-parallel-lint/php-console-highlighter: 1.0.0
- php-parallel-lint/php-parallel-lint: 1.4.0
- phpunit/phpunit: 9.6.16
README
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.