An extension to extra-streamlit-components · PyPI | (Github) , I added browser cookie support. You can preserve data between sessions, update, get, and delete browser cookies. Newly added cookies with this module is strictly same-site, so you don’t have to worry about privacy. Highly advised to be on Streamlit >= 0.84.0 for seamless experience as it harnesses state management for faster performance
The tab feature is really cool. I tested it with 6+ elements and some are of course hidden. I was able to drag the tabs but it took me a while to find out that it could be done.
It may be nice to show something like a scrollbar in the bottom if there are many elements. What do you think?
I think the pip package’s main.py shall work fine without any additional setup. I tried figuring share.streamlit.io out on but my invitation request hasn’t been processed in days.
cc: @jrieke
Awesome. I did and it works. Do you want to add the instruction on github on how to add expires_at? I had to dig through the source code for it, and it was worth it Thank you for taking this on quickly.
@Mohamed How to get the cookie from a existed internet address
and judge its specific cookie is exist or not?
if not exist, do redirect operation, only get valid cookie, user can view the app page.
how can we make it come true?
I had made it use asp, it very convenient
like this:
<%
if len(request.cookies("cookie_name"))<1 then
response.redirect("specific address to finish identity check & back to current page url")
end if
%>
Well @BeyondMyself this is not considered as a limitiation of this library rather an application design problem. I propose you do either of the following:
Make this authentication mechanism using a REST API where you expect the response to be a cookie or token which then you can use stx to add the cookie.
Make the identity check redirect to the app with a query parameter set to the token. i.e. 127.0.0.1:8501?token=1234S3cr3t then use built in streamlit commands to extract that query parameter and then set it as a cookie
I can remeber seeing a post on this forum mentioning successfully using AOuth2 which as far as I know, does the identity check in a new window browser and returns an auth token, which then you can also add to the browser cookie using stx
Good Luck!
Hi @Mohamed I’ve implemented a secure access with web authentication, and encoded the user information with JWT in the cookies.
But using this package, when I explore the cookies, I cannot see the required cookie.
Do you know if there is any limitation to shoe “secure” cookies?.
Let me attach some pictures to illustrate the problem:
Hi @MarceTU , one of those 2 not visible cookies must have been set in an other way that through CookieManager so I can’t confirm that behaviour.
However, I am aware of a bug where getting all cookies after setting a cookie might miss showing the newly added cookie. A work around to that is to call get_all twice back to back and the latest call shall return all cookies correctly.
Have a good one!