Custom email encryption / customize data saved in sessions

I just switched from auth.js (formerly next auth) to better auth, and I don't quite understand how to set up custom sessions. With auth.js, you could decide what was stored in the session. Since I only store all emails as hashes and encrypted versions in the database, I don't want them to be visible in the session as plain text. So, how can I adapt the session accordingly? I also need additional fields (role, for example) in my session that are also stored in my database.
1 Reply
The Untraceable
The Untraceable15h ago
For additional fields: https://www.better-auth.com/docs/concepts/typescript#additional-fields Not sure about the custom sessions
TypeScript | Better Auth
Better Auth TypeScript integration.

Did you find this page helpful?