Home > Backend Development > PHP Tutorial > Why Does Laravel Throw a \'Session Store Not Set on Request\' Error in a New Project?

Why Does Laravel Throw a \'Session Store Not Set on Request\' Error in a New Project?

Patricia Arquette
Release: 2024-11-03 03:21:02
Original
990 people have browsed it

Why Does Laravel Throw a

Laravel "Session Store Not Set on Request" Issue

Question:

In a newly created Laravel project, when accessing login or register routes, an error occurs:

ErrorException in Request.php line 775:
Session store not set on request. (View: C:\Users\Matthew\Documents\test\resources\views\auth\register.blade.php)
Copy after login

Despite not modifying any core files and only adding routes and views, the issue persists.

Answer:

To use session state and CSRF protection, the web middleware must be applied to the affected routes. This is typically done by grouping the routes within a web middleware closure:

<code class="php">Route::group(['middleware' => ['web']], function () {
    // your routes here
});</code>
Copy after login

This ensures that the routes within the closure utilize the features provided by the web middleware, resolving the "Session Store Not Set on Request" error.

The above is the detailed content of Why Does Laravel Throw a \'Session Store Not Set on Request\' Error in a New Project?. For more information, please follow other related articles on the PHP Chinese website!

source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Latest Articles by Author
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template