Skip to content

Conversation

@sohamx0
Copy link

@sohamx0 sohamx0 commented Jan 4, 2026

Issue

On browser refresh, authenticated users were redirected back to the login screen because Streamlit resets session_state on reload.

Solution

Implemented persistent session handling using browser cookies:

  • Session data is saved on login (regular, OAuth, and guest)
  • Session is restored on app load before auth checks
  • Guest users are handled separately
  • Sessions expire after 7 days
  • Session data is cleared on logout

Changes

  • Added cookie-based session manager
  • Restored session state before authentication guard
  • No changes to existing authentication flow

Testing

  • Login persists across page refresh
  • Logout clears session correctly
  • Guest login persists across refresh
  • No regressions observed

Notes

A brief CachedWidgetWarning may appear during initial load due to internal behavior of extra-streamlit-components.
This warning is transient and does not affect functionality.

@eccentriccoder01
Copy link
Owner

Great work @sohamx0! Kindly provide a streamlit cloud deployment link of your updated fork/PR commit

@sohamx0
Copy link
Author

sohamx0 commented Jan 5, 2026

Hi @eccentriccoder01,

I’ve deployed the updated PR branch to Streamlit Cloud for verification:
https://talkheal-session-fix.streamlit.app/

@sohamx0
Copy link
Author

sohamx0 commented Jan 12, 2026

Hi @eccentriccoder01 just following up on this PR.
The Streamlit Cloud deployment link is already shared above and everything is passing checks.
Let me know if any changes are needed from my side.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Make the Existing Authentication Persistent

2 participants