Skip to content

cookie set / delete is not sync operation #77

@doutv

Description

@doutv

Set cookie and delete cookie are not sync operation.
I don't know when it finish. sometimes it success, sometimes it just fail without raising error. Very confusing.

SLEEP_TIME_FOR_COKKIE = 5

async def get_cookie_manager_instance():
    cm = stx.CookieManager()
    with st.spinner("Initializing..."):
        time.sleep(SLEEP_TIME_FOR_COKKIE)
    return cm

def main():
  # Initialize cookie manager in session state
  if 'cm' not in st.session_state:
      st.session_state.cm = await get_cookie_manager_instance()
  COOKIE_MANAGER = st.session_state.cm
  COOKIE_MANAGER.set("token", "value", secure=True)
  time.sleep(SLEEP_TIME_FOR_COKKIE)
  # Cannot see cookie in chrome developer tool
  assert COOKIE_MANAGER.get("token") != None

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions