How to automatically remove access permanently to shiny app after fixed time once they are logged in?

I have standard plan, i give access to users though their email id.

I want to write code that the access is removed after certain time once they are successfully logged in.

Can anyone write a simple app with time limit or show any example/link where it has been discussed earlier?

Will appreciate it so much.


Hi @amoeba,

You can achieve this with some pretty straightforward JavaScript. Not sure how safe/robust it is, but it works...


ui <- fluidPage(
  h1('My Shiny app'),
  p('You will be disconnected after 5 seconds...'),
      document.addEventListener('DOMContentLoaded', (event) => {
        setTimeout(() => {Shiny.onInputChange('disconnect', true)}, 5000)
      } )

server <- function(input, output, session) {
  observeEvent(input$disconnect, {
    if (input$disconnect) shiny::stopApp()

shinyApp(ui, server)

Hi @mattwarkentin ,
Thanks for replying.

I tried above code, while the app closes when testing on Rstudio, but it just disconnect on browser, and if you refresh the website, you get access again.

Is there anyway that once login is successful first time, after certain time access is removed permanently?

Can you refer to any article , code on stackoverflow etc, which discuss this point in details?

Thank you so much again

Also app should be stopped for only one particular user whose time limit is over and should not affect other logged in users in anyways (who have logged in recently and their time limit is not over).

@amoeba I don't think you will be able to get that level of control over user management without some full-featured enterprise level resource.

Maybe RStudio Connect or ShinyProxy offer those kinds of features, but I have never seen something like this out in the wild. Sorry, I have no additional resources to share.

I believe doesn't allow you to identify specific users beyond knowing that they are individual users so there is no straight forward way to do it (I might be wrong, if there is a way to access the user email on runtime), as @mattwarkentin says, since enterprise level tools like RStudio Connect and ShinyProxy have some user management capabilities, they might have that functionality or at least provide the means to implement the logic within the app more easily.

I think you could still implement it by using an authentication management package like shinymanager to identify specific users and implement the authorization logic with a combination of code and metadata stored on a persisten database. Not a trivial task though.