CSRF Tokens doesn't match after switching to Database Session [laravel]

Jian

Resident Weeb
Contributor
Sep 2, 2011
687
437
After changing the value of "SESSION_DRIVER" to "database" in the environment file and running the migration below, the CSRF token stops being correct everywhere.

Session Migration:
PHP:
Schema::create('sessions', function ($table) {
    $table->string('id')->unique();
    $table->integer('user_id')->nullable();
    $table->string('ip_address', 45)->nullable();
    $table->text('user_agent')->nullable();
    $table->text('payload');
    $table->integer('last_activity');
});

I even tried adding a Routing group with the "web" middleware and it still did nothing.
Route.php
Code:
Route::group(['middleware' => ['web']], function() {
    //Log in
Route::get('/', ['as' => 'Index', 'uses' => 'Project\HomepageController@Index']);
Route::get('/login', ['as' => 'LoginGet', 'uses' => 'Project\LoginController@login']);
Route::post('/login', ['as' => 'LoginPost', 'uses' => 'Project\LoginController@loginPost']);

//Register
Route::get('/register', ['as' => 'Register', 'uses' => 'Project\LoginController@Register']);
Route::post('/register', ['as' => 'RegisterPost', 'uses' => 'Project\LoginController@Register']);

//Activate Email
Route::get('/email/activate/{code}', ['as' => 'ActivateEmail', 'uses' => 'Project\LoginController@ActivateEmail']);
});

The error that I get
Code:
TokenMismatchException in VerifyCsrfToken.php line 67:

Any solution to this problem?
 

Users who are viewing this thread

Top