Skip to content

'JS-cookies' in Shiny

License

Unknown, MIT licenses found

Licenses found

Unknown
LICENSE
MIT
LICENSE.md
Notifications You must be signed in to change notification settings

ColinFay/glouton

Repository files navigation

glouton

The goal of glouton is to handle browser cookies in shiny.

It's built on top of js-cookie.

Installation

You can install the released version of glouton from github with:

remotes::install_github("ColinFay/glouton")

Function reference

In the UI, add use_glouton() to integrate {glouton} to your app.

In the server, you can use:

  • add_cookie to add a session cookie. Takes a name, content, and the session object.
  • fetch_cookies / fetch_cookie to get all or one cookie. Takes the session and input objects and a name for fetch_cookie()
  • remove_cookie to remove one cookie. Takes a name of a cookie and the session object.

Example

This is a basic example which shows you how to solve a common problem:

library(glouton)
library(shiny)
ui <- function(request){
  tagList(
    use_glouton(),
    textInput("cookie_name", "cookie name"),
    textInput("cookie_content", "cookie content"),
    actionButton("setcookie", "Add cookie"),
    actionButton("getcookie", "get cookie"),
    verbatimTextOutput("cook"),
    verbatimTextOutput("one")
  )
}

server <- function(input, output){

  r <- reactiveValues()

  observeEvent( input$setcookie , {
    add_cookie(input$cookie_name, input$cookie_content)
  })
  observeEvent( input$getcookie , {
    r$cook <- fetch_cookies()
  })

  output$cook <- renderPrint({
    r$cook
  })

}

shinyApp(ui, server)

TO DO

About

'JS-cookies' in Shiny

Resources

License

Unknown, MIT licenses found

Licenses found

Unknown
LICENSE
MIT
LICENSE.md

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published