Creating session specific folder


#1

My app need to save some files to a temp folder, maybe pack them into a zip later. The folder need to be session specific: each session should have their own folder to avoid interference.

Right now I create a timestamped folder in server function, so it should be session specific if no user connect to server at same second. I can reduce the possibility by further including fractional seconds, but I’m wondering if there is a better method.

I looked at Session object but not sure about it. Is there any session specific information I can use, like some token or hash value?

I also thought about a random hash per session. If hosted by a server, is it possible for multiple worker’s random number generator generate same number (random number is tricky in parallel environment)?


#2

Shiny generates a random ID for every session, which you could use. You can access it like session$token.


#3

I found that token but not sure if this is a right way to use it. Thanks!


#4

I had the same question. Did session$token turn out to be the solution? Thanks!