php-session-serializer
Provides methods like PHP's session_encode and session_decode that don't mess with $_SESSION
Wikimedia\PhpSessionSerializer Class Reference

Provides for encoding and decoding session arrays to PHP's serialization formats. More...

Static Public Member Functions

static setLogger (LoggerInterface $logger)
 Set the logger to which to log. More...
 
static setSerializeHandler ()
 Try to set session.serialize_handler to a supported format. More...
 
static encode (array $data)
 Encode a session array to a string, using the format in session.serialize_handler. More...
 
static decode ( $data)
 Decode a session string to an array, using the format in session.serialize_handler. More...
 
static encodePhp (array $data)
 Encode a session array to a string in 'php' format. More...
 
static decodePhp ( $data)
 Decode a session string in 'php' format to an array. More...
 
static encodePhpBinary (array $data)
 Encode a session array to a string in 'php_binary' format. More...
 
static decodePhpBinary ( $data)
 Decode a session string in 'php_binary' format to an array. More...
 
static encodePhpSerialize (array $data)
 Encode a session array to a string in 'php_serialize' format. More...
 
static decodePhpSerialize ( $data)
 Decode a session string in 'php_serialize' format to an array. More...
 

Static Protected Attributes

static $logger
 

Detailed Description

Provides for encoding and decoding session arrays to PHP's serialization formats.

Supported formats are:

  • php
  • php_binary
  • php_serialize

WDDX is not supported, since it breaks on all sorts of things.

Member Function Documentation

◆ decode()

static Wikimedia\PhpSessionSerializer::decode (   $data)
static

Decode a session string to an array, using the format in session.serialize_handler.

Parameters
string$dataSession data. Use the same caution in passing user-controlled data here that you would to PHP's unserialize function.
Returns
array|null Data, or null on failure
Exceptions

◆ decodePhp()

static Wikimedia\PhpSessionSerializer::decodePhp (   $data)
static

Decode a session string in 'php' format to an array.

Note
Generally you'll use self::decode() instead of this method.
Parameters
string$dataSession data. Use the same caution in passing user-controlled data here that you would to PHP's unserialize function.
Returns
array|null Data, or null on failure
Exceptions

◆ decodePhpBinary()

static Wikimedia\PhpSessionSerializer::decodePhpBinary (   $data)
static

Decode a session string in 'php_binary' format to an array.

Note
Generally you'll use self::decode() instead of this method.
Parameters
string$dataSession data. Use the same caution in passing user-controlled data here that you would to PHP's unserialize function.
Returns
array|null Data, or null on failure
Exceptions

◆ decodePhpSerialize()

static Wikimedia\PhpSessionSerializer::decodePhpSerialize (   $data)
static

Decode a session string in 'php_serialize' format to an array.

Note
Generally you'll use self::decode() instead of this method.
Parameters
string$dataSession data. Use the same caution in passing user-controlled data here that you would to PHP's unserialize function.
Returns
array|null Data, or null on failure
Exceptions

◆ encode()

static Wikimedia\PhpSessionSerializer::encode ( array  $data)
static

Encode a session array to a string, using the format in session.serialize_handler.

Parameters
array$dataSession data
Returns
string|null Encoded string, or null on failure
Exceptions

◆ encodePhp()

static Wikimedia\PhpSessionSerializer::encodePhp ( array  $data)
static

Encode a session array to a string in 'php' format.

Note
Generally you'll use self::encode() instead of this method.
Parameters
array$dataSession data
Returns
string|null Encoded string, or null on failure

◆ encodePhpBinary()

static Wikimedia\PhpSessionSerializer::encodePhpBinary ( array  $data)
static

Encode a session array to a string in 'php_binary' format.

Note
Generally you'll use self::encode() instead of this method.
Parameters
array$dataSession data
Returns
string|null Encoded string, or null on failure

◆ encodePhpSerialize()

static Wikimedia\PhpSessionSerializer::encodePhpSerialize ( array  $data)
static

Encode a session array to a string in 'php_serialize' format.

Note
Generally you'll use self::encode() instead of this method.
Parameters
array$dataSession data
Returns
string|null Encoded string, or null on failure

◆ setLogger()

static Wikimedia\PhpSessionSerializer::setLogger ( LoggerInterface  $logger)
static

Set the logger to which to log.

Parameters
LoggerInterface$loggerThe logger

◆ setSerializeHandler()

static Wikimedia\PhpSessionSerializer::setSerializeHandler ( )
static

Try to set session.serialize_handler to a supported format.

This may change the format even if the current format is also supported.

Returns
string Format set
Exceptions

The documentation for this class was generated from the following file: