glouton icon indicating copy to clipboard operation
glouton copied to clipboard

Problem with remove_cookie() ?

Open man-jo opened this issue 5 years ago • 1 comments

Hello Colin, Thanks for this very useful package ! I am not at all expert in cookie management and javascript but if I can use it to retain user session in association with the shinymanager package it would be wonderful :). I have noticed a problem with the way I try to use the remove_cookie() function, cf below your example modified to add a button to remove all cookies:

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"),
    actionButton("rmcookies", "remove cookie(s)"),
    verbatimTextOutput("cook"),
    verbatimTextOutput("one")
  )
}

server <- function(input, output, session){
  
  r <- reactiveValues()
  
  observeEvent( input$setcookie , {
    add_cookie(input$cookie_name, input$cookie_content)
  })
  observeEvent( input$getcookie , {
    r$cook <- fetch_cookies()
  })
  observeEvent(input$rmcookies , {
    cookienames <- names(r$cook)
    for(cname in cookienames){
      remove_cookie(cname)
    }
  })
  output$cook <- renderPrint({
    r$cook
  })
}

shinyApp(ui, server)

It seems that I can't remove the cookies with the function remove_ccokies(). Is it a bug or a misuse of the function in the example above ?

Best regards, Jonas

man-jo avatar Feb 24 '20 16:02 man-jo

Hey Jonas,

Sorry for the late reply.

It should have been solved via the last PR, can you confirm by reinstalling the package ?

Cheers, colin

ColinFay avatar Jul 21 '20 07:07 ColinFay