本文整理汇总了PHP中lithium\storage\Session::clear方法的典型用法代码示例。如果您正苦于以下问题:PHP Session::clear方法的具体用法?PHP Session::clear怎么用?PHP Session::clear使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类lithium\storage\Session
的用法示例。
在下文中一共展示了Session::clear方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testEncryptStrategyWithPhpAdapter
public function testEncryptStrategyWithPhpAdapter()
{
$config = array('name' => 'encryptInt');
Session::config(array($config['name'] => array('adapter' => 'Php', 'strategies' => array('Encrypt' => array('secret' => 's3cr3t')))));
Session::clear($config);
$key = 'test';
$value = 'value';
$this->assertTrue(Session::write($key, $value, $config));
$this->assertEqual($value, Session::read($key, $config));
$this->assertTrue(Session::delete($key, $config));
$this->assertNull(Session::read($key, $config));
Session::clear($config);
$this->assertTrue(Session::write('foo', 'bar', $config));
$this->assertEqual('bar', Session::read('foo', $config));
$this->assertTrue(Session::write('foo', 'bar1', $config));
$this->assertEqual('bar1', Session::read('foo', $config));
Session::clear($config);
$this->assertTrue(Session::write($key, $value, $config));
$this->assertEqual($value, Session::read($key, $config));
}
示例2: testEncryptedStrategy
public function testEncryptedStrategy()
{
$this->skipIf(!MockEncrypt::enabled(), 'The Mcrypt extension is not installed or enabled.');
$key = 'foobar';
$adapter = new Memory();
Session::config(array('primary' => array('adapter' => $adapter, 'filters' => array(), 'strategies' => array('lithium\\tests\\mocks\\storage\\session\\strategy\\MockEncrypt' => array('secret' => $key)))));
$value = array('foo' => 'bar');
Session::write('test', $value);
$this->assertEqual(array('foo' => 'bar'), Session::read('test'));
$this->assertTrue(Session::check('test'));
$this->assertTrue(Session::check('test', array('strategies' => false)));
$encrypted = Session::read('test', array('strategies' => false));
$this->assertNotEqual($value, $encrypted);
$this->assertTrue(is_string($encrypted));
$result = Session::read('test');
$this->assertEqual($value, $result);
$result = Session::clear(array('strategies' => false));
$this->assertNull(Session::read('test'));
$this->assertFalse(Session::check('test'));
$this->assertFalse(Session::check('test', array('strategies' => false)));
$savedData = array('test' => $value);
$encrypt = new MockEncrypt(array('secret' => $key));
$result = $encrypt->encrypt($savedData);
$this->assertEqual($encrypted, $result);
$result = $encrypt->decrypt($encrypted);
$this->assertEqual($savedData, $result);
}
示例3: testStrategies
public function testStrategies()
{
Session::config(array('primary' => array('adapter' => new Memory(), 'filters' => array(), 'strategies' => array('lithium\\storage\\cache\\strategy\\Json'))));
Session::write('test', array('foo' => 'bar'));
$this->assertEqual(array('foo' => 'bar'), Session::read('test'));
$this->assertTrue(Session::check('test'));
$this->assertTrue(Session::check('test', array('strategies' => false)));
$result = Session::read('test', array('strategies' => false));
$this->assertEqual('{"foo":"bar"}', $result);
$result = Session::clear(array('strategies' => false));
$this->assertNull(Session::read('test'));
$this->assertFalse(Session::check('test'));
$this->assertFalse(Session::check('test', array('strategies' => false)));
}
示例4: testEncryptStrategyWithPhpAdapter
public function testEncryptStrategyWithPhpAdapter()
{
$this->skipIf(PHP_SAPI === 'cli', 'No PHP session support in cli SAPI.');
$this->skipIf(!extension_loaded('mcrypt'), 'The `mcrypt` extension is not loaded.');
$config = array('name' => 'encryptInt');
Session::config(array($config['name'] => array('adapter' => 'Php', 'strategies' => array('Encrypt' => array('secret' => 's3cr3t')))));
Session::clear($config);
$key = 'test';
$value = 'value';
$this->assertTrue(Session::write($key, $value, $config));
$this->assertEqual($value, Session::read($key, $config));
$this->assertTrue(Session::delete($key, $config));
$this->assertNull(Session::read($key, $config));
Session::clear($config);
$this->assertTrue(Session::write('foo', 'bar', $config));
$this->assertEqual('bar', Session::read('foo', $config));
$this->assertTrue(Session::write('foo', 'bar1', $config));
$this->assertEqual('bar1', Session::read('foo', $config));
Session::clear($config);
$this->assertTrue(Session::write($key, $value, $config));
$this->assertEqual($value, Session::read($key, $config));
}
示例5: testSessionClear
/**
* Tests clearing all session data from one or all adapters.
*
* @return void
*/
public function testSessionClear()
{
Session::config(array('primary' => array('adapter' => new Memory(), 'filters' => array()), 'secondary' => array('adapter' => new Memory(), 'filters' => array())));
Session::write('key1', 'value', array('name' => 'primary'));
Session::write('key2', 'value', array('name' => 'secondary'));
Session::clear(array('name' => 'secondary'));
$this->assertTrue(Session::check('key1'));
$this->assertFalse(Session::check('key2'));
Session::write('key2', 'value', array('name' => 'secondary'));
Session::clear();
$this->assertFalse(Session::check('key1'));
$this->assertFalse(Session::check('key2'));
}