PHP Class lithium\storage\session\adapter\Php

This adapter provides basic support for write, read and delete session handling, as well as allowing these three methods to be filtered as per the Lithium filtering system.
Inheritance: extends lithium\core\Object
Datei anzeigen Open project: unionofrad/lithium Class Usage Examples

Protected Properties

Property Type Description
$_defaults Default ini settings for this session adapter. Will disabl cookie lifetime, set cookies to HTTP only and the cache_limiter to 'nocache'.

Public Methods

Method Description
__construct ( array $config = [] ) : void Constructor. Takes care of setting appropriate configurations for this object. Also sets session ini settings.
check ( string $key, array $options = [] ) : Closure Checks if a value has been set in the session.
clear ( array $options = [] ) : Closure Clears all keys from the session.
delete ( string $key, array $options = [] ) : Closure Delete value from the session
enabled ( ) : boolean Determines if PHP sessions are enabled.
isStarted ( ) : boolean Obtain the status of the session.
key ( string $key = null ) : mixed Sets or obtains the session ID.
overwrite ( array &$old, array $new ) : boolean Overwrites session keys and values.
read ( null | string $key = null, array $options = [] ) : Closure Read a value from the session.
write ( string $key, mixed $value, array $options = [] ) : Closure Write a value to the session.

Protected Methods

Method Description
_init ( ) Initialization of the session.
_start ( ) : boolean Starts the session.

Method Details

__construct() public method

Constructor. Takes care of setting appropriate configurations for this object. Also sets session ini settings.
See also: lithium\storage\session\adapter\Php::$_defaults
public __construct ( array $config = [] ) : void
$config array Configuration options matching the pattern `'session.*'` are interpreted as session ini settings. Please consult the PHP documentation for further information. A few ini settings are set by default here and will overwrite those from your php.ini. To disable sending a cache limiter set `'session.cache_limiter'` to `false`.
return void

_init() protected method

Initialization of the session.
protected _init ( )

_start() protected method

Starts the session.
protected _start ( ) : boolean
return boolean `true` if session successfully started (or has already been started), `false` otherwise.

check() public method

Checks if a value has been set in the session.
public check ( string $key, array $options = [] ) : Closure
$key string Key of the entry to be checked.
$options array Options array. Not used for this adapter method.
return Closure Function returning boolean `true` if the key exists, `false` otherwise.

clear() public method

Clears all keys from the session.
public clear ( array $options = [] ) : Closure
$options array Options array. Not used for this adapter method.
return Closure Function returning boolean `true` on successful clear, `false` otherwise.

delete() public method

Delete value from the session
public delete ( string $key, array $options = [] ) : Closure
$key string The key to be deleted.
$options array Options array. Not used for this adapter method.
return Closure Function returning boolean `true` if the key no longer exists in the session, `false` otherwise

enabled() public static method

Determines if PHP sessions are enabled.
public static enabled ( ) : boolean
return boolean Returns `true` if enabled (PHP session functionality can be disabled completely), `false` otherwise.

isStarted() public method

Obtain the status of the session.
public isStarted ( ) : boolean
return boolean True if a session is currently started, False otherwise. If PHP 5.4 then we know, if PHP 5.3 then we cannot tell for sure if a session has been closed.

key() public method

Sets or obtains the session ID.
public key ( string $key = null ) : mixed
$key string Optional. If specified, sets the session ID to the value of `$key`.
return mixed Session ID, or `null` if the session has not been started.

overwrite() public method

Overwrites session keys and values.
public overwrite ( array &$old, array $new ) : boolean
$old array Reference to the array that needs to be overwritten. Will usually be `$_SESSION`.
$new array The data that should overwrite the keys/values in `$old`.
return boolean Always `true`.

read() public method

Read a value from the session.
public read ( null | string $key = null, array $options = [] ) : Closure
$key null | string Key of the entry to be read. If no key is passed, all current session data is returned.
$options array Options array. Not used for this adapter method.
return Closure Function returning data in the session if successful, `false` otherwise.

write() public method

Write a value to the session.
public write ( string $key, mixed $value, array $options = [] ) : Closure
$key string Key of the item to be stored.
$value mixed The value to be stored.
$options array Options array. Not used for this adapter method.
return Closure Function returning boolean `true` on successful write, `false` otherwise.

Property Details

$_defaults protected_oe property

Default ini settings for this session adapter. Will disabl cookie lifetime, set cookies to HTTP only and the cache_limiter to 'nocache'.
protected $_defaults