当前位置: 首页>>代码示例>>PHP>>正文


PHP Session::clear方法代码示例

本文整理汇总了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));
 }
开发者ID:davidpersson,项目名称:FrameworkBenchmarks,代码行数:20,代码来源:SessionTest.php

示例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);
 }
开发者ID:newmight2015,项目名称:Blockchain-2,代码行数:27,代码来源:SessionTest.php

示例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)));
 }
开发者ID:WarToaster,项目名称:HangOn,代码行数:14,代码来源:SessionTest.php

示例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));
 }
开发者ID:fedeisas,项目名称:lithium,代码行数:22,代码来源:SessionTest.php

示例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'));
 }
开发者ID:EHER,项目名称:chegamos,代码行数:18,代码来源:SessionTest.php


注:本文中的lithium\storage\Session::clear方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。