ktosiek / streamlit-cookies-manager

Access and change cookies from your Streamlit script
58 stars 40 forks source link

Does this package work with Safari? #9

Closed Odrec closed 7 months ago

Odrec commented 8 months ago

I have an app that currently is using this package but it doesn't work in Safari. Specifically if I do something like:

st.write('Test 1')

cookies = EncryptedCookieManager(
    prefix=os.getenv("COOKIES_PREFIX"),
    password=os.getenv("COOKIES_PASSWORD")
)

st.write('Test 2')

if not cookies.ready():
    # Wait for the component to load and send us current cookies.
    st.spinner()
    st.stop()

st.write('Test 3')

I can see the Test 1 and Test 2 on the interface but it never gets to Test 3 which I assume means it never has the cookies ready and it's stopping the streamlit app. I even added some sleep time of 2 seconds before the cookies.ready() check but it doesn't work either, I also set all the restrictions for cookies in Safari to the minimum but it didn't work and the browser console doesn't show any error. All other browsers work fine. Has someone tested a streamlit app in Safari using this and what's their experience? Can someone think of a work around?

Elijas commented 7 months ago

I confirm that it does not work on Safari.

Does setting the cookies work or not? Because there are other ways to read the cookies

Odrec commented 7 months ago

I confirm that it does not work on Safari.

Does setting the cookies work or not? Because there are other ways to read the cookies

Could you tell me how? That's a good question. I have inspected the console in Safari, Sometimes the single cookie we use shows up, sometimes it doesn't but it always stops at the st.stop() regardless of if there are cookies set or not.

Elijas commented 7 months ago

I confirm that it does not work on Safari.

Does setting the cookies work or not? Because there are other ways to read the cookies

Could you tell me how? That's a good question. I have inspected the console in Safari, Sometimes the single cookie we use shows up, sometimes it doesn't but it always stops at the st.stop() regardless of if there are cookies set or not.

Delete the "if cookies.ready()" and continue as normal (you will not know what cookies are there), but attempt save new cookies. You can check whether the cookies got saved through the browser itself.

If this works we can try to implement a workaround, where we would use something else to read cookies, but use this library to write cookies

Odrec commented 7 months ago

I confirm that it does not work on Safari.

Does setting the cookies work or not? Because there are other ways to read the cookies

Could you tell me how? That's a good question. I have inspected the console in Safari, Sometimes the single cookie we use shows up, sometimes it doesn't but it always stops at the st.stop() regardless of if there are cookies set or not.

Delete the "if cookies.ready()" and continue as normal (you will not know what cookies are there), but attempt save new cookies. You can check whether the cookies got saved through the browser itself.

If this works we can try to implement a workaround, where we would use something else to read cookies, but use this library to write cookies

Thanks for trying to help. It seems the issue was due to a streamlit bug. Now it's solved for the next streamlit release: https://github.com/streamlit/streamlit/issues/8362