lithium\storage\Session::read PHP Method

read() public static method

Reads a value from a persistent session store.
public static read ( string $key = null, array $options = [] ) : mixed
$key string Key to be read.
$options array Optional parameters that this method accepts: - `'name'` _string_: To force the read from a specific adapter, specify the name of the configuration (i.e. `'default'`) here. - `'strategies'` _boolean_: Indicates whether or not a configuration's applied strategy classes should be enabled for this operation. Defaults to `true`.
return mixed Read result on successful session read, `null` otherwise.
    public static function read($key = null, array $options = array())
    {
        $defaults = array('name' => null, 'strategies' => true);
        $options += $defaults;
        $method = ($name = $options['name']) ? static::adapter($name)->read($key, $options) : null;
        $settings = static::_config($name);
        if (!$method) {
            foreach (array_keys(static::$_configurations) as $name) {
                if ($method = static::adapter($name)->read($key, $options)) {
                    break;
                }
            }
            if (!$method || !$name) {
                return null;
            }
        }
        $filters = $settings['filters'] ?: array();
        $result = static::_filter(__FUNCTION__, compact('key', 'options'), $method, $filters);
        if ($options['strategies']) {
            $options += array('key' => $key, 'mode' => 'LIFO', 'class' => __CLASS__);
            return static::applyStrategies(__FUNCTION__, $name, $result, $options);
        }
        return $result;
    }

Usage Example

コード例 #1
0
 public function post()
 {
     $token = Session::read('oauth.access');
     $result = Consumer::post('/1/statuses/update.json', array('status' => 'Testing my status'), compact('token'));
     echo $result;
     exit;
 }
All Usage Examples Of lithium\storage\Session::read