改进Session类的flush方法 判断是否开启session

This commit is contained in:
thinkphp
2016-10-20 10:59:28 +08:00
parent cbd4c2c98c
commit 0117543df0

View File

@@ -217,14 +217,16 @@ class Session
*/ */
public static function flush() public static function flush()
{ {
$item = self::get('__flash__'); if (self::$init) {
$item = self::get('__flash__');
if (!empty($item)) { if (!empty($item)) {
$time = $item['__time__']; $time = $item['__time__'];
if ($_SERVER['REQUEST_TIME_FLOAT'] > $time) { if ($_SERVER['REQUEST_TIME_FLOAT'] > $time) {
unset($item['__time__']); unset($item['__time__']);
self::delete($item); self::delete($item);
self::set('__flash__', []); self::set('__flash__', []);
}
} }
} }
} }