Skip to content

Commit

Permalink
Added Session::get_once, get and delete a value from the session data…
Browse files Browse the repository at this point in the history
…, fixes #3012
  • Loading branch information
Woody Gilk committed Jul 14, 2010
1 parent 1ef65b9 commit 0c6c357
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions classes/kohana/session.php
Expand Up @@ -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.
*
Expand Down

0 comments on commit 0c6c357

Please sign in to comment.