session

Value

clientData
A reactiveValues object that contains information about the client.
  • allowDataUriScheme is a logical value that indicates whether the browser is able to handle URIs that use the data: scheme.

  • pixelratio reports the "device pixel ratio" from the web browser, or 1 if none is reported. The value is 2 for Apple Retina displays.

  • singletons - for internal use
  • url_protocol, url_hostname, url_port, url_pathname, url_search, and url_hash_initial can be used to get the components of the URL that was requested by the browser to load the Shiny app page. These values are from the browser's perspective, so neither HTTP proxies nor Shiny Server will affect these values. The url_search value may be used with parseQueryString to access query string parameters.

clientData also contains information about each output. output_outputId_width and output_outputId_height give the dimensions (using offsetWidth and offsetHeight) of the DOM element that is bound to outputId, and output_outputId_hidden is a logical that indicates whether the element is hidden. These values may be NULL if the output is not bound.

input
The session's input object (the same as is passed into the Shiny server function as an argument).

isClosed()
A function that returns TRUE if the client has disconnected.

onEnded(callback)
Synonym for onSessionEnded.

onFlush(func, once=TRUE)
Registers a function to be called before the next time (if once=TRUE) or every time (if once=FALSE) Shiny flushes the reactive system. Returns a function that can be called with no arguments to cancel the registration.

onFlushed(func, once=TRUE)
Registers a function to be called after the next time (if once=TRUE) or every time (if once=FALSE) Shiny flushes the reactive system. Returns a function that can be called with no arguments to cancel the registration.

onSessionEnded(callback)
Registers a function to be called after the client has disconnected. Returns a function that can be called with no arguments to cancel the registration.

output
The session's output object (the same as is passed into the Shiny server function as an argument).

reactlog
For internal use.

registerDataObj(name, data, filterFunc)
Publishes any R object as a URL endpoint that is unique to this session. name must be a single element character vector; it will be used to form part of the URL. filterFunc must be a function that takes two arguments: data (the value that was passed into registerDataObj) and req (an environment that implements the Rook specification for HTTP requests). filterFunc will be called with these values whenever an HTTP request is made to the URL endpoint. The return value of filterFunc should be a Rook-style response.

request
An environment that implements the Rook specification for HTTP requests. This is the request that was used to initiate the websocket connection (as opposed to the request that downloaded the web page for the app).

sendCustomMessage(type, message)
Sends a custom message to the web page. type must be a single-element character vector giving the type of message, while message can be any RJSONIO-encodable value. Custom messages have no meaning to Shiny itself; they are used soley to convey information to custom JavaScript logic in the browser. You can do this by adding JavaScript code to the browser that calls Shiny.addCustomMessageHandler(type, function(message){...}) as the page loads; the function you provide to addCustomMessageHandler will be invoked each time sendCustomMessage is called on the server.

sendInputMessage(inputId, message)
Sends a message to an input on the session's client web page; if the input is present and bound on the page at the time the message is received, then the input binding object's receiveMessage(el, message) method will be called. sendInputMessage should generally not be called directly from Shiny apps, but through friendlier wrapper functions like updateTextInput.

Description

Shiny server functions can optionally include session as a parameter (e.g. function(input, output, session)). The session object is an environment that can be used to access information and functionality relating to the session. The following list describes the items available in the environment; they can be accessed using the $ operator (for example, session$clientData$url_search).