In my case I resolve mine when I had a debugging tool called barryvddh/laravel-debugbar by jnoordsij
Here is the link of the debugging tool which I recommend
Installation method
Require this package with composer. It is recommended to only require the package for development.
composer require barryvdh/laravel-debugbar --dev
Laravel uses Package Auto-Discovery, so doesn't require you to manually add the ServiceProvider.
The Debugbar will be enabled when APP_DEBUG is true.
If you use a catch-all/fallback route, make sure you load the Debugbar ServiceProvider before your own App ServiceProviders.
Laravel without auto-discovery:
If you don't use auto-discovery, add the ServiceProvider to the providers array in config/app.php
Barryvdh\Debugbar\ServiceProvider::class,
If you want to use the facade to log messages, add this to your facades in app.php:
'Debugbar' => Barryvdh\Debugbar\Facades\Debugbar::class,
The profiler is enabled by default, if you have APP_DEBUG=true. You can override that in the config (debugbar.enabled) or by setting DEBUGBAR_ENABLED in your .env. See more options in config/debugbar.php You can also set in your config if you want to include/exclude the vendor files also (FontAwesome, Highlight.js and jQuery). If you already use them in your site, set it to false. You can also only display the js or css vendors, by setting it to 'js' or 'css'. (Highlight.js requires both css + js, so set to true for syntax highlighting)
Copy the package config to your local config with the publish command:
php artisan vendor:publish --provider="Barryvdh\Debugbar\ServiceProvider"
While using debug bar tool I've seen that Laravel initially selects * from sessions
,
having a column name id containing string so, I replaced the datatype from int to string
Then I looked for the migration file having sessions table file
I removed the duplicate migration file sessions table file
database/migrations/202_08_02_063945_create_sessions_table.php
I replaced the columns inside the sessions table
From
public function up()
{
Schema::create('sessions', function (Blueprint $table) {
$table->increments('id');
$table->foreignId('user_id')->nullable()->index();
$table->string('ip_address', 45)->nullable();
$table->text('user_agent')->nullable();
$table->longText('payload');
$table->integer('last_activity')->index();
});
}
To
public function up()
{
Schema::create('sessions', function (Blueprint $table) {
$table->string('id')->primary();
$table->foreignId('user_id')->nullable()->index();
$table->string('ip_address', 45)->nullable();
$table->text('user_agent')->nullable();
$table->longText('payload');
$table->integer('last_activity')->index();
});
}
Then migrate the sessions table only
In my case:
php artisan migrate:refresh --path=/database/migrations/202_08_02_063945_create_sessions_table.php
Then serve
php artisan serve
I hope this solves error 419 on registration and login issue including page session expired error
All the credits for solving belongs to jnoordsij for making the debugging tool
return;
you can callreturn redirect()->back();
. From what I can see, the app has nothing to do after the post request. Maybe you can redirect it to a view after processing the request. – Honestlyfile
forSESSION_DRIVER
in.env
it works fine. Why is the database based session not working. – Anemometryvendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/VerifyCsrfToken.php
line 67 to know why – Bryansessions
table for a different purpose. After Changing this table name to a more suited one and ranartisan session:table
and refreshed migration everything is working fine – Anemometrylifetime
inconfig/session.php
? – Troutman<meta name="csrf-token" content="{{ csrf_token() }}">
and include another in your form via@csrf
. Use developer inspection view on the browser to check if they both match and you don't have some javascript messing up the CSRF data in the form (as was my case). It's a good place to start troubleshooting. – Eighteen