think\Session::clear PHP Method

clear() public static method

清空session数据
public static clear ( string | null $prefix = null ) : void
$prefix string | null 作用域(前缀)
return void
    public static function clear($prefix = null)
    {
        empty(self::$init) && self::boot();
        $prefix = !is_null($prefix) ? $prefix : self::$prefix;
        if ($prefix) {
            unset($_SESSION[$prefix]);
        } else {
            $_SESSION = [];
        }
    }

Usage Example

コード例 #1
0
ファイル: helper.php プロジェクト: livingvirus/cyfthink
function session($name, $value = '')
{
    if (is_array($name)) {
        // 初始化
        \think\Session::init($name);
    } elseif (is_null($name)) {
        // 清除
        \think\Session::clear($value);
    } elseif ('' === $value) {
        // 获取
        return \think\Session::get($name);
    } elseif (is_null($value)) {
        // 删除session
        return \think\Session::delete($name);
    } else {
        // 设置session
        return \think\Session::set($name, $value);
    }
}
All Usage Examples Of think\Session::clear