php-session-serializer
Provides methods like PHP's session_encode and session_decode that don't mess with $_SESSION
Loading...
Searching...
No Matches
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.
 
static setSerializeHandler ()
 Try to set session.serialize_handler to a supported format.
 
static encode (array $data)
 Encode a session array to a string, using the format in session.serialize_handler.
 
static decode ( $data)
 Decode a session string to an array, using the format in session.serialize_handler.
 
static encodePhp (array $data)
 Encode a session array to a string in 'php' format.
 
static decodePhp ( $data)
 Decode a session string in 'php' format to an array.
 
static encodePhpBinary (array $data)
 Encode a session array to a string in 'php_binary' format.
 
static decodePhpBinary ( $data)
 Decode a session string in 'php_binary' format to an array.
 
static encodePhpSerialize (array $data)
 Encode a session array to a string in 'php_serialize' format.
 
static decodePhpSerialize ( $data)
 Decode a session string in 'php_serialize' format to an array.
 

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
DomainException
InvalidArgumentException

◆ 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
InvalidArgumentException

◆ 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
InvalidArgumentException

◆ 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
InvalidArgumentException

◆ 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
DomainException

◆ 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
DomainException

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