Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Not able to delete a cookie. #1

Open
aegeavaz-pfizer opened this issue Jun 20, 2022 · 5 comments
Open

Not able to delete a cookie. #1

aegeavaz-pfizer opened this issue Jun 20, 2022 · 5 comments

Comments

@aegeavaz-pfizer
Copy link

Hi ktosiek...

I'm testing your cookie manager, and looks good, but I'm not able to delete a cookie...

I have tried:

del cookies[name]
cookies.delitem(name)

call save after this... and any combination works...

is there any way to delete an existing cookie?

Thank you very much.

@zealpatel1990
Copy link

Yes please, liked this library better then stx. only missing is delete functionality.

@Odrec
Copy link

Odrec commented Feb 11, 2024

i have the same problem


# This should be on top of your script
cookies = EncryptedCookieManager(
    # This prefix will get added to all your cookie names.
    # This way you can run your app on Streamlit Cloud without cookie name clashes with other apps.
    prefix="ktosiek/streamlit-cookies-manager/",
    # You should really setup a long COOKIES_PASSWORD secret if you're running on Streamlit Cloud.
    password=os.environ.get("COOKIES_PASSWORD"),
)

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

print(cookies.pop("session"))
cookies.__delitem__("session")

I tried both and it doesn't work. Any ideas how to fix this?

@SajjadAemmi
Copy link

@Odrec You can try this:

# unset username in cookies
cookies['username'] = ""

and then:

if "username" in cookies.keys() and str(cookies['username']):
    # my coockies has username
else:
    # my coockies hasn't username

@Riorty
Copy link

Riorty commented Aug 10, 2024

Someone managed to find another way?

@maopareja
Copy link

Cookie assignment is not supported, it generates this error: TypeError: 'StreamlitCookies' object does not support item assignment

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants