File: README.md

package info (click to toggle)
mediawiki 1%3A1.39.13-1~deb12u1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 320,416 kB
  • sloc: php: 815,516; javascript: 601,264; sql: 11,218; python: 4,863; xml: 3,080; sh: 990; ruby: 82; makefile: 78
file content (54 lines) | stat: -rw-r--r-- 1,729 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
[![Latest Stable Version]](https://packagist.org/packages/wikimedia/php-session-serializer) [![License]](https://packagist.org/packages/wikimedia/php-session-serializer)

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

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

```php
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.


---
[phpencode]: https://php.net/manual/en/function.session-encode.php
[phpdecode]: https://php.net/manual/en/function.session-decode.php
[read]: https://php.net/manual/en/sessionhandlerinterface.read.php
[write]: https://php.net/manual/en/sessionhandlerinterface.write.php
[Latest Stable Version]: https://poser.pugx.org/wikimedia/php-session-serializer/v/stable.svg
[License]: https://poser.pugx.org/wikimedia/php-session-serializer/license.svg