diff options
author | Frédéric Guillot <fred@kanboard.net> | 2014-12-28 11:28:50 -0500 |
---|---|---|
committer | Frédéric Guillot <fred@kanboard.net> | 2014-12-28 11:28:50 -0500 |
commit | 34d7450d3c13342715e90ec21bceaa13e1baa876 (patch) | |
tree | a2d8f2f22ad3fe9b56f01fe2db0357f9b963e660 /app/Core/Session.php | |
parent | 88d84073aecbe8bdc5f10825b6d7ca6b81c5f7b1 (diff) |
Template helpers refactoring
Diffstat (limited to 'app/Core/Session.php')
-rw-r--r-- | app/Core/Session.php | 50 |
1 files changed, 35 insertions, 15 deletions
diff --git a/app/Core/Session.php b/app/Core/Session.php index 3305eca3..0e5f7426 100644 --- a/app/Core/Session.php +++ b/app/Core/Session.php @@ -2,13 +2,15 @@ namespace Core; +use ArrayAccess; + /** * Session class * * @package core * @author Frederic Guillot */ -class Session +class Session implements ArrayAccess { /** * Sesion lifetime @@ -59,7 +61,7 @@ class Session ini_set('session.entropy_length', '32'); ini_set('session.hash_bits_per_character', 6); - // If session was autostarted with session.auto_start = 1 in php.ini destroy it + // If the session was autostarted with session.auto_start = 1 in php.ini destroy it if (isset($_SESSION)) { session_destroy(); } @@ -88,19 +90,17 @@ class Session $_SESSION = array(); // Destroy the session cookie - if (ini_get('session.use_cookies')) { - $params = session_get_cookie_params(); - - setcookie( - session_name(), - '', - time() - 42000, - $params['path'], - $params['domain'], - $params['secure'], - $params['httponly'] - ); - } + $params = session_get_cookie_params(); + + setcookie( + session_name(), + '', + time() - 42000, + $params['path'], + $params['domain'], + $params['secure'], + $params['httponly'] + ); // Destroy session data session_destroy(); @@ -127,4 +127,24 @@ class Session { $_SESSION['flash_error_message'] = $message; } + + public function offsetSet($offset, $value) + { + $_SESSION[$offset] = $value; + } + + public function offsetExists($offset) + { + return isset($_SESSION[$offset]); + } + + public function offsetUnset($offset) + { + unset($_SESSION[$offset]); + } + + public function offsetGet($offset) + { + return isset($_SESSION[$offset]) ? $_SESSION[$offset] : null; + } } |