1 [![Latest Stable Version]](https://packagist.org/packages/wikimedia/php-session-serializer) [![License]](https://packagist.org/packages/wikimedia/php-session-serializer)
6 php-session-serializer is a PHP library that provides methods that work like
7 PHP's [session_encode][phpencode] and [session_decode][phpdecode]
8 functions, but don't mess with the `$_SESSION` superglobal.
10 It supports the `php`, `php_binary`, and `php_serialize` serialize handlers.
11 `wddx` is not supported, since it is inferior to `php` and `php_binary`.
18 use Wikimedia\PhpSessionSerializer;
20 // (optional) Send logs to a PSR-3 logger
21 PhpSessionSerializer::setLogger( $logger )
23 // (optional) Ensure that session.serialize_handler is set to a usable value
24 PhpSessionSerializer::setSerializeHandler();
26 // Encode session data
27 $string = PhpSessionSerializer::encode( $array );
29 // Decode session data
30 $array = PhpSessionSerializer::decode( $string );
36 composer install --prefer-dist
43 This library was created to support custom session handler [read][] and
44 [write][] methods that are more useful than blindly storing the serialized data
45 that PHP gives to custom handlers.
49 [phpencode]: https://php.net/manual/en/function.session-encode.php
50 [phpdecode]: https://php.net/manual/en/function.session-decode.php
51 [read]: https://php.net/manual/en/sessionhandlerinterface.read.php
52 [write]: https://php.net/manual/en/sessionhandlerinterface.write.php
53 [Latest Stable Version]: https://poser.pugx.org/wikimedia/php-session-serializer/v/stable.svg
54 [License]: https://poser.pugx.org/wikimedia/php-session-serializer/license.svg