Hello @blackary.
Here below a snippet of the code. I first take the inputs and save them in session states. Then I check for them and if they have been changed I update them.
city = st.text_input('Città', placeholder="e.g. Ferrara", key = "field").capitalize()
province = st.text_input('Provincia (sigla)', placeholder="e.g. FE", max_chars=2).upper()
state = "Italia" #st.text_input('Stato', placeholder="e.g. Italia").capitalize()
border = st.selectbox("Confine di ricerca", ("comune", "provincia"))
if "border" not in st.session_state:
st.session_state["border"] = border
if "geo" not in st.session_state:
st.session_state["geo"] = (city, province)
#doing things not related with session states
if border != st.session_state["border"] or (city != st.session_state["geo"][0] and province != st.session_state["geo"][1]):
#doing other things not related... and finally update session states
st.session_state["border"] = border
st.session_state["geo"] = (city, province)
Here is the entire Python script where I use session states
The web app is active at choosing.club. Eventually you can try from there, opening two tabs of Chrome, logging in with a pseudo mail (mail@mail.com), and repeating my experiment I reported in: