Shiny undocumented session$token variable

As far as I could (easily) find, the session$token variable isn't documented at I found it on StackOverflow at

Is there any reason that I shouldn't use this as an identifier for the session for logging purposes?

1 Like

poke? I haven't found any other documentation on this session variable.

It really depends on your logging goals. The shiny session token is internal, and links an active browser session to an R process. Also be aware that the token attribute of the session object isn't formal part of shiny's "exposed" API, so it may be subject to change.

If you are interested in logging at a user level, or aggregating across sessions, than this token may not be useful. You also should be careful as there are "reconnect" cases where the same session will reconnect with a different token.

But aside from those caveats, its probably ok to use the token as an identifier for when you server function is called.

In case you are interested, there is documented and exposed client data as well:

And in authenticated sessions on RStudio Connect you'll also see session$user and in some cases session$groups

Thanks @slopp. That helps!

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.