Support the ongoing development of Laravel.io →
Authentication Session Configuration
Last updated 2 years ago.
0

I figured it out! I had the error as there are 2 missing pieces of middleware on my api route group. I added the following 2 middlewares to the api middleware group and then added that group to my API routes and it fixed the issue!

    \App\Http\Middleware\EncryptCookies::class,
    \Illuminate\Session\Middleware\StartSession::class,
0

Can you post the fixed code as a reference to anyone having the same problem ?

0

Just add the web middleware to your route entry like this:

Route::get('/file', 'FileController@createNewFile')->middleware('web');

This group already contains he middleware needed for persistent sessions in ajax calls

Last updated 8 years ago.
0

hellfull said:

Can you post the fixed code as a reference to anyone having the same problem ?

Put that 2 lines of code to app/Http/Kernel.php

    protected $middlewareGroups = [ 
        'web' => [
            // ...
        ],  

        'api' => [
            \App\Http\Middleware\EncryptCookies::class,          // <------- ADD THIS
            \Illuminate\Session\Middleware\StartSession::class, // <------ ADD THIS
            // ...
        ],  
    ];
0

Sign in to participate in this thread!

Eventy

Your banner here too?

Moderators

We'd like to thank these amazing companies for supporting us

Your logo here?

Laravel.io

The Laravel portal for problem solving, knowledge sharing and community building.

© 2024 Laravel.io - All rights reserved.