Set-udcookie CookieOptions?


#1

hey all,
where do I find some info on CookieOptions ?
I tryed to do a hashtable

-CookieOptions @{expires= (get-date).AddYears(1)}
no luck :slight_smile:


#2

It’s a CookieOptions class.

So you can do something like:

$CookieOptions = New-Object -TypeName microsoft.aspnetcore.http.cookieoptions
$CookieOptions.Expires = (Get-Date).AddYears(1)

#3

Do I need to download that dll or something?
it’s not working on my PC.
I get:


#4

If you import UD first I think it should find that type.


#5

Okey, Important, Powershell Core is casesensitive

$CookieOptions = New-Object -TypeName Microsoft.AspNetCore.Http.CookieOptions


#6

Okey, I got the CookieOptions right, but Chrome still show N/A:

also this code dont set the Cookie ?

New-UDCheckbox -Checked:$session:AlertSound -Id ‘Alert Sound’ -Label ‘Alert Sound’ -OnChange {
$CookieOptions = New-Object -TypeName Microsoft.AspNetCore.Http.CookieOptions
$CookieOptions.Expires = (Get-Date).AddYears(1)
$CookieOptions.MaxAge = New-TimeSpan -days 365
Set-UDCookie -name AlertSound -value $EventData -CookieOptions $CookieOptions
$session:AlertSound = [system.convert]::ToBoolean($EventData)
}