Is there a way to store some custom datas from the user inside the cookie generated by the Identity API ?
We are building an multi-tenant application, and so multiple companies can access to the same instance of our application. That's why I need, for a specific user, to store company code from the user in the identity cookie to retrieve the datas from the user when he returned on the web application after closing the browser.
you could achieve that by implementing a custom UserClaimsPrincipalFactory and adding a custom claim for your store number, then it would be stored in the cookie with the other claims.
Below is example code from my project where I am adding several custom claims including a SiteGuid because my scenario is also multi-tenant
Then in Startup you need to register your custom factory so it gets injected and used instead of the default one
another approach is to use Claims Transformation, however this approach does not store the extra claims in a cookie but instead updates the claims on each request, that is it adds more claims to the ones from the cookie for the lifetime of the request but doesn't modify the claims in the cookie.
then in startup.cs: