#1842·loco

Server-side sessions and remember-me: which implementation would you accept? (follow-up to #561 / #633)

Author: gerardpCreated Sep 28, 2026Updated Sep 28, 2026

Feature Request

Is your feature request related to a problem? Please describe.

Loco has no server-side sessions today. The recommended path for browser apps is a JWT read from a cookie (JWTLocation::Cookie), which works for authentication but leaves two gaps for server-rendered and Inertia/HTMX apps:

  • No revocation. A session can't be ended from the server (log a user out, "sign out of all devices", lock an account) without building a token denylist.
  • No real remember-me. It can only be approximated with a longer JWT expiry, with the same revocation problem.

Rails, Laravel and Django all ship sessions and remember-me out of the box. For "Rust on Rails", it's probably the most visible missing piece when building a classic web app.

This was discussed in #561, where @jondot outlined a direction I think is still right: an encrypted and signed cookie store by default in development, and a server-side store required in production. #633 implemented a version of it with tower-sessions. It was closed without merging, with the comment that the team needed "to think through a better implementation", and #561 was later closed without a session module landing.

Describe the solution you'd like

Rather than propose one design and have it rejected again, I'd like to ask what shape you would accept. A starting point:

  • Sessions: a Session extractor backed by tower-sessions, with the store chosen in config (cookie for development, database or Redis for production), and with the release/production guard from #561.
  • Remember-me: a long-lived random token stored hashed in the database and rotated on use, the way Rails and Laravel do it, so it can be revoked individually or all at once.
  • Auth integration: an extractor, alongside auth::JWT, that resolves the current user from the session or the remember-me token.

Open questions for you:

  1. Is tower-sessions acceptable as the foundation, or would you rather own the implementation?
  2. Should the default store for production be the database (no extra infrastructure) or Redis?
  3. Should this land in core, or as an initializer/extension crate like loco-openapi-initializer?
  4. What was missing in #633, so a new attempt doesn't repeat it?

Happy to test an implementation and give feedback from a real app that needs it.

Describe alternatives you've considered

  • JWT in a cookie (current approach): no server-side revocation, and remember-me is only a longer expiry.
  • Adding tower-sessions as a layer per project: it works, since Loco is Axum underneath, but every app rebuilds the same config, store setup, auth integration and remember-me logic, which is the kind of convention a batteries-included framework usually owns.