We rolled our own sessions for a client app (DB sessions, bcrypt, TOTP). Lessons:
- Store a hash of the session token in the database, never the token itself.
- Rate limit login per (IP, identifier), and make error messages generic.
- Step-up auth for sensitive actions is easy when you own the session table.
- Write tests for every flow, especially password reset.
Would I do it again? For an app with money features, yes; the control was worth it. For a weekend project, use a library.
ByteNomad Dev Studio · Next.js, Postgres, bots · milestone escrow
- Reacted by
