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)
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>
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!