本文整理匯總了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);
}