api() |>
api_datastore(storr::driver_environment()) |>
api_get("hello", function(datastore) {
if (length(datastore$session) == 0) {
datastore$global$count <- (datastore$global$count %||% 0) + 1
datastore$session$not_first_visit <- TRUE
paste0("Welcome. You are visitor #", datastore$global$count)
} else {
"Welcome back"
}
})
Run the code above in your browser using DataLab