Set-UDCookie and Get-UDCookie not working

Hi,

I’m trying to use Set-UDCookie and Set-UDCookie functions, but it seams that it doesn’t work or causing errors like “You cannot call a method on a null-valued expression.” I’ve tested it as per examples in GitHub.
Can anybody share a success experience of using this functions?

Seems buggy.

You can work around this by using the response directly.

$Response.Cookies.Append("MyCookie", "test")

$Request.Cookies['MyCookie']

It fail with the same error, as corresponding commandlet:

You cannot call a method on a null-valued expression.
At C:\scripts\Dashboard\dashboard.ps1:79 char:1

  • $Response.Cookies.Append(“TestCookie”, “TestValue”)

Maybe it has some pre-requisites?

Hi,

I got some more time to play with UDDashboard. I’ve updated to latest version of UDD, but issue persist.
With some more troubleshooting, I got to understanding, that Set-UDCookie only works in -Endpoint (as it is, amazingly =) stated in documentation). But what to do, if I need to execute it inside -OnChange?
I’ve spent some time searching on this forum and around it for solutions. The only solution that I’ve found - was to create new-udendpoint and feed it with argument. But this Endpoint inside -OnChange didn’t run at all. So I’m confused. Any advice here?

Hi Muravsky

Did you try to create a new-udelement div with an -endpoint ?

I’ve added inside -OnChange section of New-UDSelect following:

New-UDElement -Tag “div” -Endpoint {
Show-UDToast -Message “$EventData selected!” -Duration 5000
Set-UDCookie -Name “Team” -Value $EventData
}

Section inside -Endpoint didn’t execute.