25 if (isset ( $_SESSION [$arrayKey] )) {
26 $array = $_SESSION [$arrayKey];
27 if (! is_array ( $array ))
46 $array = self::getArray ( $arrayKey );
47 $_SESSION [$arrayKey] = $array;
48 $search = array_search ( $value, $array );
49 if ($search === FALSE && $add) {
50 $_SESSION [$arrayKey] [] = $value;
53 unset ( $_SESSION [$arrayKey] [$search] );
54 $_SESSION [$arrayKey] = array_values ( $_SESSION [$arrayKey] );
69 return self::addOrRemoveValueFromArray ( $arrayKey, $value,
false );
82 return self::addOrRemoveValueFromArray ( $arrayKey, $value,
true );
96 return $_SESSION [$key];
109 if (isset ( $_SESSION [$key] )) {
124 public static function session($key, $default = NULL) {
126 return isset ( $_SESSION [$key] ) ? $_SESSION [$key] : $default;
138 public static function get($key, $default = NULL) {
140 return isset ( $_SESSION [$key] ) ? $_SESSION [$key] : $default;
150 public static function set($key, $value) {
151 $_SESSION [$key] = $value;
161 public static function delete($key) {
163 unset ( $_SESSION [$key] );
173 public static function inc($key, $inc = 1) {
174 return self::set ( $key, self::get ( $key, 0 ) + $inc );
184 public static function dec($key, $dec = 1) {
185 return self::set ( $key, self::get ( $key, 0 ) - $dec );
195 public static function concat($key, $str, $default = NULL) {
196 return self::set ( $key, self::get ( $key, $default ) . $str );
206 public static function apply($key, $callback, $default = NULL) {
207 $value = self::get ( $key, $default );
208 if (is_string ( $callback ) && function_exists ( $callback )) {
209 $value = call_user_func ( $callback, $value );
210 } elseif (is_callable ( $callback )) {
211 $value = $callback ( $value );
215 return self::set ( $key, $value );
225 public static function Walk($callback, $userData = null) {
227 array_walk ( $_SESSION, $callback, $userData );
237 public static function replace($keyAndValues) {
239 $_SESSION = array_replace ( $_SESSION, $keyAndValues );
260 if (! isset ( $_SESSION )) {
264 if (isset ( self::$name )) {
265 \session_name ( self::$name );
277 return isset ( $_SESSION );
289 return isset ( $_SESSION [$key] );
296 if (! self::isStarted ())
299 $_SESSION = array ();
301 if (\ini_get (
"session.use_cookies" )) {
302 $params = \session_get_cookie_params ();
303 \setcookie ( \session_name (),
'', \time () - 42000, $params [
"path"], $params [
"domain"], $params [
"secure"], $params [
"httponly"] );
static dec($key, $dec=1)
Decrement the value at the key index in session.
static exists($key)
Returns true if the key exists in Session.
static session($key, $default=NULL)
Returns the value stored at the key position in session.
static isStarted()
Returns true if the session is started.
static apply($key, $callback, $default=NULL)
Applies a callback function to the value at the key index in session.
static Walk($callback, $userData=null)
Apply a user supplied function to every member of Session array.
static concat($key, $str, $default=NULL)
Adds a string at the end of the value at the key index in session.
static getBoolean($key)
Returns a boolean stored at the key position in session.
static replace($keyAndValues)
Replaces elements from Session array with $keyAndValues.
static terminate()
Terminates the active session.
static setBoolean($key, $value)
Sets a boolean value at key position in session.
static getAll()
Returns the associative array of session vars.
static start($name=null)
Start new or resume existing session.
static inc($key, $inc=1)
Increment the value at the key index in session.
static removeValueFromArray($arrayKey, $value)
Removes a value from an array in session.
static getArray($arrayKey)
Returns an array stored in session variable as $arrayKey.
static addValueToArray($arrayKey, $value)
Adds a value from an array in session.
static addOrRemoveValueFromArray($arrayKey, $value, $add=true)
Adds or removes a value from an array in session.