What is the correct way of getting/setting values in session$userData for Shiny applications? The documentation states:
userData: An environment for app authors and module/package authors to store whatever session-specific data they want.
And is userData only available when executing in apps on the Shiny server after the user has logged in?
I tried to work with session$userData while running an app from within RStudio IDE, but session$userData is NULL, and I get errors saying "cannot add bindings to a locked environment".
library(shiny)
ui <- fluidPage()
server <- function(input, output, session) {
# Returns NULL
print(session$userData)
# will throw an error
session$userData$test <- "test value"
attr(session$userData,"test") <- "test value"
}
shinyApp(ui = ui, server = server)
Possibly related: