本文整理汇总了PHP中Cake\Network\Session::consume方法的典型用法代码示例。如果您正苦于以下问题:PHP Session::consume方法的具体用法?PHP Session::consume怎么用?PHP Session::consume使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Cake\Network\Session
的用法示例。
在下文中一共展示了Session::consume方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testConsume
/**
* Test consuming session data.
*
* @return void
*/
public function testConsume()
{
$session = new Session();
$session->write('Some.string', 'value');
$session->write('Some.array', ['key1' => 'value1', 'key2' => 'value2']);
$this->assertEquals('value', $session->read('Some.string'));
$value = $session->consume('Some.string');
$this->assertEquals('value', $value);
$this->assertFalse($session->check('Some.string'));
$value = $session->consume('');
$this->assertNull($value);
$value = $session->consume(null);
$this->assertNull($value);
$value = $session->consume('Some.array');
$expected = ['key1' => 'value1', 'key2' => 'value2'];
$this->assertEquals($expected, $value);
$this->assertFalse($session->check('Some.array'));
}
示例2: consume
/**
* Used to read and delete a session values for a key.
*
* In your controller: $this->Session->consume('Controller.sessKey');
*
* @param string $name the name of the session key you want to read
* @return mixed value from the session vars
*/
public function consume($name)
{
return $this->_session->consume($name);
}