Permalink
Browse files

Added Session::get_once, get and delete a value from the session data…

…, fixes #3012
  • Loading branch information...
Woody Gilk
Woody Gilk committed Jul 14, 2010
1 parent 1ef65b9 commit 0c6c3579609403f0f2ec22500053f68ac383ec21
Showing with 18 additions and 0 deletions.
  1. +18 −0 classes/kohana/session.php
@@ -173,6 +173,24 @@ public function get($key, $default = NULL)
return array_key_exists($key, $this->_data) ? $this->_data[$key] : $default;
}
/**
* Get and delete a variable from the session array.
*
* $bar = $session->get_once('bar');
*
* @param string variable name
* @param mixed default value to return
* @return mixed
*/
public function get_once($key, $default = NULL)
{
$value = $this->get($key, $default);
unset($this->_data[$key]);
return $value;
}
/**
* Set a variable in the session array.
*

0 comments on commit 0c6c357

Please sign in to comment.