Storing Browser Cookies from Streamlit Space
I am currently building a Streamlit demo in hugging face that uses analytics tracking. I want to give users an option to opt of of this tracking and store this information into a browser cookie so that any time they open up the demo again, they are already opted out of analytics tracking. The solution I am trying to use for this is thestreamlit-cookies-managerpackage. When I test this functionality locally, it seems to work properly (once I opt out of the tracking on one run, it saves this preference for all future runs of the program on my browser), but the cookie storage does not seem to work in my Hugging Face space (If I inspect the page, I never see the cookie appear in the browser and when I reload the browser, the preference is not saved).Can you please help me figure out why this is not saving in my browser and any suggestions for possible solutions?Thank you!
2024-09-25T17:17:54Z
Perhaps:huggingface.coCookie limitations in SpacesWe’re on a journey to advance and democratize artificial intelligence through open source and open science.
2024-09-26T21:11:10Z
Hi John,Thanks for the suggestion but I have already seen this page. I don’t believe this is the issue because I am using the Streamlit SDK (not Docker), and the parameter referenced in this page is properly set by Streamlit, by default.
2024-09-26T21:28:49Z
So there are no error messages in the Spaces logs that are related to syntax or options, or that something was rejected by the server, right?So the process itself is working, and the server thinks it has been successfully processed.But you are not receiving it.In the following example, it is just a lack of waiting time, but HF Spaces often behaves unexpectedly differently from a normal web site.Depending on the cookie specification, for example, a cookie targeting a specific IP address or URL would be incompatible with HF, which has multiple aliases in Spaces by default, and there are quite a few behaviors that are implicitly prohibited, whether they are related to cookies or not. Well, it’s a VM. There is no complaint to HF about the less-used behaviors, so they are left as they are.A less smart solution would be to have the configuration saved as a JSON file. There are a few people doing this, but I haven’t seen any spaces that actively use cookies…If I could just know if there is a chance that it will work in the end or not, I could work backwards to find the problem.Streamlit – 31 Aug 23Finally I find a right way to use extra-cookie.manager!Using Streamlitsession-stateVow! This is true! I had an issue where fleetingly I would not find the cookies… And then it would suddenly appear after a few seconds…  So my streamlit app would fleetingly display “access denied” and then immediately load the page… So weird!!  I...