|
@ -42,6 +42,13 @@ class Session |
|
|
*/ |
|
|
*/ |
|
|
public static function get($key = null, $default = null) |
|
|
public static function get($key = null, $default = null) |
|
|
{ |
|
|
{ |
|
|
|
|
|
if (!self::$started) { |
|
|
|
|
|
if (self::isExists()) { |
|
|
|
|
|
self::start(); |
|
|
|
|
|
} else { |
|
|
|
|
|
return $default; |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
if (null === $key) { |
|
|
if (null === $key) { |
|
|
return $_SESSION; |
|
|
return $_SESSION; |
|
|
} |
|
|
} |
|
@ -57,6 +64,9 @@ class Session |
|
|
*/ |
|
|
*/ |
|
|
public static function set($spec, $value = null) |
|
|
public static function set($spec, $value = null) |
|
|
{ |
|
|
{ |
|
|
|
|
|
if (!self::$started) { |
|
|
|
|
|
self::start(); |
|
|
|
|
|
} |
|
|
if (is_array($spec)) { |
|
|
if (is_array($spec)) { |
|
|
foreach ($spec as $key => $value) { |
|
|
foreach ($spec as $key => $value) { |
|
|
self::set($key, $value); |
|
|
self::set($key, $value); |
|
@ -73,6 +83,13 @@ class Session |
|
|
*/ |
|
|
*/ |
|
|
public static function del($key) |
|
|
public static function del($key) |
|
|
{ |
|
|
{ |
|
|
|
|
|
if (!self::$started) { |
|
|
|
|
|
if (self::isExists()) { |
|
|
|
|
|
self::start(); |
|
|
|
|
|
} else { |
|
|
|
|
|
return; |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
if (isset($_SESSION[$key])) { |
|
|
if (isset($_SESSION[$key])) { |
|
|
unset($_SESSION[$key]); |
|
|
unset($_SESSION[$key]); |
|
|
} |
|
|
} |
|
@ -141,7 +158,7 @@ class Session |
|
|
|
|
|
|
|
|
public static function isExists() |
|
|
public static function isExists() |
|
|
{ |
|
|
{ |
|
|
if (ini_get('session.use_cookies') == '1' && isset($COOKIE[session_name()])) { |
|
|
|
|
|
|
|
|
if (isset($_COOKIE[session_name()])) { |
|
|
return true; |
|
|
return true; |
|
|
} |
|
|
} |
|
|
return false; |
|
|
return false; |
|
@ -149,6 +166,9 @@ class Session |
|
|
|
|
|
|
|
|
public static function start() |
|
|
public static function start() |
|
|
{ |
|
|
{ |
|
|
|
|
|
if (self::$started) { |
|
|
|
|
|
return; |
|
|
|
|
|
} |
|
|
self::$started = true; |
|
|
self::$started = true; |
|
|
session_start(); |
|
|
session_start(); |
|
|
self::regenerateId(); |
|
|
self::regenerateId(); |
|
@ -188,7 +208,7 @@ class Session |
|
|
*/ |
|
|
*/ |
|
|
public static function expireSessionCookie() |
|
|
public static function expireSessionCookie() |
|
|
{ |
|
|
{ |
|
|
if (isset($COOKIE[session_name()])) { |
|
|
|
|
|
|
|
|
if (isset($_COOKIE[session_name()])) { |
|
|
$params = session_get_cookie_params(); |
|
|
$params = session_get_cookie_params(); |
|
|
setcookie( |
|
|
setcookie( |
|
|
session_name(), |
|
|
session_name(), |
|
@ -200,4 +220,4 @@ class Session |
|
|
); |
|
|
); |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
} |