pass php variable to shiny

1,605 views
Skip to first unread message

Dr. Hans Hansen

unread,
Dec 8, 2014, 9:58:06 AM12/8/14
to shiny-...@googlegroups.com
Hi everyone,

i embedded a shiny app in a simple html page as an iframe. The html page has a password field and i use a variable $loggedin in php to store the login status. Is there a simple way to use this variable in shiny? I figure that i probably need to use javascript?

the php file looks like this:

<html>
<body>
Hello world.
<?php
$loggedin = TRUE;
echo $loggedin;
 ?>
</body>
</html>


ui.r
shinyUI(pageWithSidebar(

  # Application title
  headerPanel("Hello Shiny!"),

  # Sidebar with a slider input for number of observations
  sidebarPanel(
    sliderInput("obs", 
                "Number of observations:", 
                min = 1,
                max = 1000, 
                value = 500)
), mainPanel( plotOutput("distPlot") ) ))



server.r

library(shiny)
shinyServer(function(input, output) {
  output$distPlot <- renderPlot({
  plot(1) # here i want a ifelse with the php-variable
})
})

Joe Cheng

unread,
Dec 8, 2014, 12:56:04 PM12/8/14
to Dr. Hans Hansen, shiny-...@googlegroups.com
This is pretty insecure... any code you could put in the HTML that would tell Shiny that the user is logged in, would be trivial to spoof. How does PHP know you're logged in? Is there a signed cookie, or a session, or something?

--
You received this message because you are subscribed to the Google Groups "Shiny - Web Framework for R" group.
To unsubscribe from this group and stop receiving emails from it, send an email to shiny-discus...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/shiny-discuss/f58333ec-c897-43a7-a4b4-e31774aaa0d2%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Dr. Hans Hansen

unread,
Dec 8, 2014, 3:40:17 PM12/8/14
to shiny-...@googlegroups.com, bea...@gmx.de
Hm, there is not really much at stake here... i have a post html form for the password and read that in php. i want data upload in the shiny app to be only available after people contacted me. i thought of having two shiny apps, one with and one without data upload and have php code which sets up the iframe link, but i didn't like the idea to keep to apps up to date.

an alternative might be to do a check for a password in shiny, like in the user account example?

Jan Stanstrup

unread,
Dec 9, 2014, 7:24:15 AM12/9/14
to shiny-...@googlegroups.com, bea...@gmx.de

Dr. Hans Hansen

unread,
Dec 11, 2014, 8:57:31 AM12/11/14
to shiny-...@googlegroups.com, bea...@gmx.de
Thanks, i'll try that!

Reply all
Reply to author
Forward
0 new messages