Guidance on Storing Temporary User Data (e.g., First Name) Only for Active Sessions

’m reaching out for guidance on the best way to store certain pieces of user information—specifically a user’s first name —in Auth0 only for the duration of the user’s active session.

I am using a SAML connection and get the first name from the Idp onto Auth0. I have 3 applications connected to Auth0, I need to pass it as claims to all the application (maybe multiple times)

We would prefer not to persist this information in Auth0 user profiles after the session ends. Essentially, we’d like to:

  • Store a user’s first name temporarily while their session is active.

  • Automatically remove or avoid persisting this data once the user’s session is terminated or expires.

Could you advise on the recommended approach to achieve this functionality?
For example:

  • Are there Auth0 features (e.g., actions, rules, hooks, token enrichment, session storage options) that support temporary, non-persistent data?

Hi @vikas.viswanathan, and thank you for the question!

The recommended approach to this use case is to write an Action that adds Custom Claims to either ID or Access Tokens using the setCustomClaims method. Here is an example:

  api.accessToken.setCustomClaim('myClaim', 'this is a private, non namespaced claim');

More info on our Doc page here. I hope this solves your use case.

Have a great day!
Teodor.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.