lithium\security\Auth::set PHP Method

set() public static method

By default, before writing the data to the session, the set() method of the named configuration's adapter receives the data to be written, and has an opportunity to modify or reject it.
public static set ( string $name, array $data, array $options = [] ) : array
$name string The name of the adapter configuration to.
$data array The user data to be written to the session.
$options array Any additional session-writing options. These may override any options set by the default session configuration for `$name`.
return array Returns the array of data written to the session, or `false` if the adapter rejects the data.
    public static function set($name, $data, array $options = array())
    {
        $params = compact('name', 'data', 'options');
        return static::_filter(__FUNCTION__, $params, function ($self, $params) {
            extract($params);
            $config = $self::invokeMethod('_config', array($name));
            $session = $config['session'];
            if ($data = $self::adapter($name)->set($data, $options)) {
                $session['class']::write($session['key'], $data, $options + $session['options']);
                return $data;
            }
            return false;
        });
    }

Usage Example

Ejemplo n.º 1
0
 public function testManualSessionFail()
 {
     $this->assertFalse(Auth::check('test'));
     $user = array('id' => 13, 'user' => 'bob');
     $this->assertFalse(Auth::set('test', $user, array('fail' => true)));
     $this->assertFalse(Auth::check('test'));
 }
All Usage Examples Of lithium\security\Auth::set