Clear session variables on page load?

Product: PowerShell Universal
Version: 1.5.14

Is there a way to force clearing the $session: variables on page load? I tried using

remove-variable session* -force

at the beginning of the page, but it doesn’t clear out the variables.

There really isn’t a good way to do this dynamically. We’d have to update the Session provider to support wildcards and Clear-Item support. For now, you’ll have to set it to $null.

    $Session:Test = 'Cool'

    New-UDButton -Text 'Toast' -OnClick {
        Show-UDToast -Message $Session:Test
    }

    New-UDButton -Text 'Clear' -OnClick {
        $Session:Test = $null
    }