How to use session $ userData correctly in Shiny

What's the correct way to get / set values ​​in session$userData

for shiny applications? The documentation states :

userData: environment for application authors and module / package authors to store any data needed for a session.

And userData

is only available when running in applications on the Shiny server after the user is logged in?

I tried to work with session$userData

while running the application from the RStudio IDE, but session$userData

- NULL

and I get errors saying "cannot add bindings to 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:

+3


source to share





All Articles