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

joedawson's avatar

Session store not set on request.

Hello guys,

Just decided to upgrade one of my projects to 5.2 (from 5.1) as I wanted to continue working on it, I've followed the 5.2 upgrade and believe have everything in order. But I'm getting an error:

RuntimeException in Request.php line 852: Session store not set on request.

After some digging around, the majority of people are suggesting it's because the web middleware is not being used - but I believe I am.

Route::group(['middleware' => ['web']], function () {

    /* -------------------------------------
    #. App
    ------------------------------------- */
    Route::get('/', ['as' => 'home', 'uses' => 'ProductsController@index']);

    /* -------------------------------------
    #. Products
    ------------------------------------- */
    Route::get('products/popular', ['as' => 'products.popular', 'uses' => 'ProductsController@popular']);
    Route::resource('products', 'ProductsController', ['only' => ['index', 'show']]);
    Route::post('products/search', ['as' => 'products.search', 'uses' => 'ProductsController@search']);

    /* -------------------------------------
    #. Categories
    ------------------------------------- */
    Route::resource('categories', 'CategoriesController', ['only' => ['index', 'show']]);

    /* -------------------------------------
    #. Authentication
    ------------------------------------- */    
    Route::get('auth/login', ['as' => 'auth.login', 'uses' => 'Auth\AuthController@getLogin']);
    Route::post('auth/login', ['as' => 'auth.attempt', 'uses' => 'Auth\AuthController@postLogin']);
    Route::get('auth/logout', ['as' => 'auth.logout', 'uses' => 'Auth\AuthController@getLogout']);
    Route::get('profile', ['as' => 'auth.profile', 'uses' => 'Auth\AuthController@getProfile']);

    Route::get('auth/register', ['as' => 'auth.register', 'uses' => 'Auth\AuthController@getRegister']);
    Route::post('auth/register', ['as' => 'auth.register.attempt', 'uses' => 'Auth\AuthController@postRegister']);

    Route::group(['prefix' => 'admin', 'middleware' => 'permitted'], function() {
        // admin routes - removed for thread to decrease crap :)
    });

});

My app/Http/Kernel.php contains the Middleware group too...

protected $middlewareGroups = [
    'web' => [
        \Corespawn\Http\Middleware\EncryptCookies::class,
        \Illuminate\Cookie\Middleware\AddQueuedCookiesToResponse::class,
        \Illuminate\Session\Middleware\StartSession::class,
        \Illuminate\View\Middleware\ShareErrorsFromSession::class,
        \Corespawn\Http\Middleware\VerifyCsrfToken::class
    ],

    'api' => [
        'throttle:60,1',
    ],
];

At least to my knowledge and per the threads I've come across, this should be correct?

But I still get the error. Any ideas?

0 likes
9 replies
tykus's avatar

Were your routes cached prior to using the 'web' middleware?

michaeldyrynda's avatar

What about clear-compiled for good measure?

If I run issues after an upgrade, I usually run through all the clear artisan commands just in case.

jlrdw's avatar

I am guessing you are using default file storage and not database.

joedawson's avatar
joedawson
OP
Best Answer
Level 18

I'd rather have not, but just ended up creating a new 5.2 project and moving everything into it.

nanosolutions's avatar

Same here.. hours of debuging, got everything in Web middleware, web works but artisan still trhought error.. checking file by file form new L5.2 still nothing :(

joedawson's avatar

@nanosolutions yeah I didn't have much luck at all with this. As you can see from previous replies, my last resort was to move everything from my existing 5.1 project into 5.2.

Please or to participate in this conversation.