I am creating an application for a private event board game table reservation manager.
Since the users need to set an username in order to create/join a table I am trying to avoid them to set it every time.
For this reason I ended up into the Streamlit Extra Component for the CookieManager and as a first attempt, I just used CookieManager for both read and write usernames and it works apart from some additional rerun that the CookieManager triggers once instantiated.
Something like:
cookie_manager = stx.CookieManager() # ā triggers a useless rerun slowing down
st.session_state[āusernameā] = cookie_manager.get(āusernameā)
# some lines later, when the users submits the (new) username:
And this approach works like a charm in my local environment (avoiding the initial annoying rerun) and if I print the whole st.context.cookies.to_dict() I get:
Hey @Marco5, this happens because Stremalit Cloud filters some headers and almost all cookies in the proxy layer. So, this is expected behavior when deployed on the Cloud.
Hello, thanks for the fast reply.
But if āStremalit Cloud filters some headers and almost all cookiesā how come CookieManager from Streamlit Extra Component works as expected in the Stremalit Cloud too (apart from the above mentioned additional rerun)?
Do you mean that the filter is performed at st.context.cookies layer?
And if so, since all the cookies are filtered out, what st.context.cookies can be used for in the Stremalit Cloud?
But if āStremalit Cloud filters some headers and almost all cookiesā how come CookieManager from Streamlit Extra Component works as expected in the Stremalit Cloud too (apart from the above mentioned additional rerun)?
I donāt know, but I assume that the CookieManager custom component reads cookie information in the front end and sends that data to the back end.
In the case of st.context, we directly read information about headers /cookies from the request, and the filtering happens before the information reaches the Streamlit app backend.
And if so, since all the cookies are filtered out, what st.context.cookies can be used for in the Stremalit Cloud?
At least right now it couldnāt be used for apps deployed on Community Cloud (and thanks for flagging this, we will mention it in documentation)!