[Bug] Crosstalk with set_query_params

main.py

import logging
import random
import streamlit as st
log = logging.getLogger(__name__)
if 'user_id' not in st.experimental_get_query_params():
    st.experimental_set_query_params(user_id=random.randint(1, 100))
st.write(f"User ID: {st.experimental_get_query_params()['user_id'][0]}")
log.info(f"User ID: {st.experimental_get_query_params()['user_id'][0]}")

Local behaviour
Visualisation) Refreshing page keeps the same user ID
Logs) One log showing the same user ID

Cloud behaviour
Visualisation) Refreshing page changes user ID
Logs) Three logs with one showing the old user ID and two showing the new one

Problem intuition
The free version of Streamlit Cloud that I use has 3 workers in parallel which are all linked to the same single log output. There is some crosstalking. The fix consists in making query_params independent for each worker’s url.

Intention
Storing user_id in the url instead of session_state so that if the user refreshes the page then user_id stays the same.