Alternative implementation of session state

You can use it as is. This might make it more obvious:

class Session:
    pass

@st.cache(allow_output_mutation=True)
def fetch_session():
    session = Session()
    session.counter = 1
    return session

def main():
    session_state = fetch_session()
    session_state.counter += 1