Creating session specific folder

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)?

1 Like

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

1 Like

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

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

In a somewhat related note. Is there a place where the session object is documented? I had this question, found the token field but I was unable to find any documentation describing what this field is used for. I think it would be good to find this information more generally.