Iām having a similar experience as many other users reporting here. I too experience the 3x loading as described and inconsistent return of cookies despite trying different ways of trying to get around that.
Itās effectively unusable for me.
Note I have found more luck with streamlit-cookies-manager Ā· PyPI
But this library does not work on safari (macOS or iOS) in my testing. There are some issues with it sometimes initially loading as well.
This is a good method. Unfortunately, it can only query the current session ID. Once I change the cookie, it still returns the previous value. Thank you
Is there a plan to support Streamlitās new cache functions? st.cache was deprecated, and neither st.cache_data nor st.cache_resource seem to work with this package.
Thanks!
Updated minimum version of Streamlit required by ExtraStreamlitComponents to replace deprecated methods with newer ones, add more control over CookieManager, and fix known bugs. Please upgrade your package to 0.1.60
Hello, I would like to mention another issue with this package. I have an application with a login page and 13 other pages. Hence, each page gets cookies from the browser to check login activity and shows the content or displays an error accordingly. However, I realized after I deployed the website that the CPU usage of the website increased significantly after some time from the deployment, which caused an extreme slowdown. When I redeployed the website, the response time was perfect. However, it slowed down after some time, again. Then, I used memory-profiler to check what was causing this slowdown. The outcome is that this package causes an extreme slowdown in the website. It is so slow that the login page does not show up anymore. How can I solve this problem?
Did you tried to save the status of logged user in st.session_state, and then just calling it in every page? Maybe the calling cookies each page is getting the app slower?
Just thinking around this issue.
I am using the cookies manager with following code. my code works in local environment, but i need to deploy my application in a docker container, and surprisingly application is not able to store cookies there, and not even throwing any error.
Could you please help me out.
Thank you.
import extra_streamlit_components as stx
from datetime import datetime, timedelta
import streamlit as st
cookie_manager = stx.CookieManager()
def set_cookie():
cookie_manager.set("my-cookie", "token-value",
expires_at=datetime.now() + timedelta(minutes=5))
def delete_cookie():
cookie_manager.delete("my-cookie")
st.button("Set cookie", on_click=set_cookie)
st.button("Delete cookie", on_click=delete_cookie)
Hi everyone! It seems cookies are not persisted when I call .save() method. Iām doing the following:
cookies = EncryptedCookieManager(prefix=COOKIE_PREFIX, password=<>)
cookies["some_key"] = "some_value"
cookies.save()
Iāve tried to call .save() after I set a key and at the end of the streamlit page but none worked. What am I missing? How can I persist cookies so that if I refresh the page or open a new tab they are restored?
If I want to override a previous added value, should I:
Hi. Your advice is right. The thing is that js script process method to long to set cookie and this is why it helping, hope one day streamlit will add in base methods their own cookie manager. And it is enough to add delay 1 sec just for set method , others work fine in my case. At any case thank you for share your case.
Iāve tried the CookieManager and was able to set and get cokies with latest version 0.1.70 but ran into similar problems lilke @rickspada , When I restart streamlip app, the cookies are avaiable in browser but not being read by the CookieManager.
Argh, running into the 4kb cookie limit. Would be nice if it could throw an error if the cookie write failed (I did not see any fail message, just my cookie not being updated if it would have gone over the 4KB limit.)
I could store into a database but with Streamlit closing sessions early (especially on mobile) a sessionID would not be enough identification. Hmm Maybe localStorage.
Interestingly, the lower you go the less consistent it seems to be (at least on Azure Containerapp / Web Apps). However, keeping it at time.sleep(1) for an authentication flow is almost unfeasible. This is the biggest pain point of the current cookie manager and really makes me want to move away from streamlit for everything that needs to be protected by authentication
@Mohamed, I am setting cookie like cookie_manager.set(āaccess_tokenā, access_token, key=1). I noticed that cookie is not getting cleared when session is opened in private window or a new browser. Is this expected behavior or a bug? Shouldnāt the cookie be cleared when opening session in new incognito tab?
Thanks for stopping by! We use cookies to help us understand how you interact with our website.
By clicking āAccept allā, you consent to our use of cookies. For more information, please see our privacy policy.
Cookie settings
Strictly necessary cookies
These cookies are necessary for the website to function and cannot be switched off. They are usually only set in response to actions made by you which amount to a request for services, such as setting your privacy preferences, logging in or filling in forms.
Performance cookies
These cookies allow us to count visits and traffic sources so we can measure and improve the performance of our site. They help us understand how visitors move around the site and which pages are most frequently visited.
Functional cookies
These cookies are used to record your choices and settings, maintain your preferences over time and recognize you when you return to our website. These cookies help us to personalize our content for you and remember your preferences.
Targeting cookies
These cookies may be deployed to our site by our advertising partners to build a profile of your interest and provide you with content that is relevant to you, including showing you relevant ads on other websites.