Multi database tenancy. How to deal with sessions.
Hello everyone!
I'm using https://tenancyforlaravel.com/ (archtechx/tenancy) package to implement multitenant functionality to my project using the multi-database tenancy approach and I'm having trouble to understand how to manage my sessions.
In order to prevent session scoping I want to use the database driver for session handling. My first question then would be the sessions table has to be in the Central database or in the Tenants database or replicated in both?
I want to use both Laravel middleware RedirectIfAuthenticated and Authenticate as usual and I want to have a Central login that would authenticate the user and redirect it to the correct subdomain, and also a Tenant login to authenticate users in the specific tenant.
Haven't used in the past year, but depending on what you want to do you can have it in the main DB or both. For example: main DB handles your tenant's sessions, tenant's DB handles tenant's users sessions.
On the other hand, multi tenancy is a pain in the a**, so unless you need to build an enterprise app that really needs that I suggest staying away from it.