Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

arsalan_ahmed_siddique's avatar

Laravel multi-tenancy with subdomains: Undefined variable $errors and Session store not set on request on login and register page

I am implementing a multi-tenant Laravel application using archtechx/tenancy package. I have set up separate databases for each tenant and have created a Tenant model to manage tenants. I am using the central database to store information about tenants and their assigned modules.

I am facing two errors on my login page:

  • Undefined variable $errors
  • Session store not set on request.

Here's what I have tried so far:

  • I have set the SESSION_DOMAIN value in my .env file to .localhost:8000
  • I have set the SESSION_DRIVER to the database in my config/session.php file.

One more thing I try, I remove all the errors variable from register.balde file and submit the form then I receive them in my central database but when I get users from UserController they are using the right tenant Database.

here is my tenant.php

Auth::routes();
Route::middleware([
    'web',
    'auth',
    InitializeTenancyByDomain::class,
    PreventAccessFromCentralDomains::class,
    CheckModuleMiddleware::class,
])->group(function () {
    Route::get('/', function () {
        // dd(\App\Models\User::all());
        return 'This is your multi-tenant application. The id of the current tenant is ' . tenant('id');
    });

    Route::resource('users', App\Http\Controllers\UserController::class);
});

Despite these efforts, I am still facing the same errors. Can anyone suggest what could be causing these errors and how to fix them?

0 likes
3 replies
MohamedTammam's avatar

In your .env add

SESSION_DOMAIN = .your-domain.test

Make sure to clear the cache after doing that.

Please or to participate in this conversation.