My app has been working with file-based sessions just fine. However, after switching to the database driver my sessions stopped working. This is exactly what happens:
The user opens the login page (a session gets created in the
sessionstable withuser_id = NULL)The user fills in his\her login credentials and submits the form (the session in the database acquires a
user_id = 1)The system tries to redirect the user to a post-login page, however by that time the session has been terminated (the session has
user_id = NULL)
To switch to the database driver I only did the following (the app was already working with file-based sessions):
Created the sessions table using:
php artisan session:tablecomposer dump-autoloadphp artisan migrate
Configured config/sessions.php as follows:
'driver' => env('SESSION_DRIVER', 'database')'connection' => 'mysql''table' => 'sessions''domain' => 'test.local'
My .env file:
DB_CONNECTION=mysqlSESSION_DRIVER=database
routes.php
Route::group(['domain' => 'test.local', 'middleware' => 'web'], function() {
Route::group(['domain' => 'test.local', 'middleware' => 'auth'], function() {
// post-login routes...
}
// show the login form
Route::get('/login', 'Auth\LoginController@showLogin');
// submit the login form
Route::post('/login', 'Auth\LoginController@submitLogin');
}
Am I missing something? Any help is much appreciated.