diff options
Diffstat (limited to 'system')
-rw-r--r-- | system/classes/session.php | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/system/classes/session.php b/system/classes/session.php index 37e5be9..3749396 100644 --- a/system/classes/session.php +++ b/system/classes/session.php @@ -57,6 +57,10 @@ class Session{ */ public static function remove($key) { Session::check(); + + if (!isset($_SESSION[$key])) + return; + $var = $_SESSION[$key]; unset($_SESSION[$key], $var); } @@ -72,4 +76,28 @@ class Session{ Session::check(); $_SESSION=array(); } + + /** + * Gets ot sets flash messages. + * If the value parameter is passed the message is set, otherwise it is retrieved. + * After the message is retrieved for the first time it is removed. + * + * @param $key The name of the flash message + * @param $val Flash message content + * @return mixed + * @access public + * @static + */ + public static function flash($key,$val = null) { + Session::check(); + $key="flash_{$key}"; + if($val != null) { + Session::set($key,$val); + }else { + $val = Session::get($key); + Session::remove($key); + } + + return $val; + } }
\ No newline at end of file |