Laravel - 未按要求设置会话存储 [英] Laravel - Session store not set on request

查看:34
本文介绍了Laravel - 未按要求设置会话存储的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我最近创建了一个新的 Laravel 项目,并按照身份验证指南进行操作.当我访问我的登录或注册路由时,出现以下错误:

Request.php 第 775 行中的 ErrorException:未按要求设置会话存储.(查看:C:UsersMatthewDocuments	est
esourcesviewsauth
egister.blade.php)

我没有编辑任何核心 Laravel 文件,我只创建了视图并将路由添加到我的 routes.php 文件

//认证路由Route::get('auth/login', ['uses' => 'AuthAuthController@getLogin', 'as' => 'login']);Route::post('auth/login', ['uses' => 'AuthAuthController@postLogin', 'as' => 'login']);Route::get('auth/logout', ['uses' => 'AuthAuthController@getLogout', 'as' => 'logout']);//注册路径Route::get('auth/register', ['uses' => 'AuthAuthController@getRegister', 'as' => 'register']);Route::post('auth/register', ['uses' => 'AuthAuthController@postRegister', 'as' => 'login']);

我对 Laravel 没有太多经验,所以请原谅我的无知.我知道有另一个问题在问同样的事情,但是这两个答案似乎都不适合我.感谢阅读!

这是我要求的 register.blade.php.

@extends('partials.main')@section('title', '测试|注册')@section('内容')<form method="POST" action="/auth/register">{!!csrf_field() !!}<div class="ui input"><input type="text" name="name" value="{{ old('name') }}" placeholder="用户名">

<div class="ui input"><input type="email" name="email" value="{{ old('email') }}" placeholder="Email">

<div class="ui input"><input type="password" name="password" placeholder="密码">

<div class="ui input"><input type="password" name="password_confirmation"placeholder="Confirm Password">

<div><button class="ui primary button" type="submit">注册</button>

</表单>@endsection

解决方案

如果您需要会话状态、CSRF 保护等,您将需要使用 Web 中间件.

Route::group(['middleware' => ['web']], function () {//你的路线在这里});

I recently created a new Laravel project and was following along the guide on Authentication. When I visit either my login or register route, I get the following error:

ErrorException in Request.php line 775:
Session store not set on request. (View: C:UsersMatthewDocuments	est
esourcesviewsauth
egister.blade.php)

I haven't edited any core Laravel files, I've only created the views and added the routes to my routes.php file

// Authentication routes
Route::get('auth/login', ['uses' => 'AuthAuthController@getLogin', 'as' => 'login']);
Route::post('auth/login', ['uses' => 'AuthAuthController@postLogin', 'as' => 'login']);
Route::get('auth/logout', ['uses' => 'AuthAuthController@getLogout', 'as' => 'logout']);

// Registration routes
Route::get('auth/register', ['uses' => 'AuthAuthController@getRegister', 'as' => 'register']);
Route::post('auth/register', ['uses' => 'AuthAuthController@postRegister', 'as' => 'login']);

I don't have much experience with Laravel, so please excuse my ignorance. I'm aware that there is another question asking this same thing, but neither of the answers seem to work for me. Thanks for reading!

Edit:

Here's my register.blade.php as requested.

@extends('partials.main')

@section('title', 'Test | Register')

@section('content')
    <form method="POST" action="/auth/register">
        {!! csrf_field() !!}
        <div class="ui input">
          <input type="text" name="name" value="{{ old('name') }}" placeholder="Username">
        </div>
        <div class="ui input">
          <input type="email" name="email" value="{{ old('email') }}" placeholder="Email">
        </div>
        <div class="ui input">
          <input type="password" name="password" placeholder="Password">
        </div>
        <div class="ui input">
          <input type="password" name="password_confirmation"placeholder="Confirm Password">
        </div>
        <div>
            <button class="ui primary button" type="submit">Register</button>
        </div>
    </form>
@endsection

解决方案

You'll need to use the web middleware if you need session state, CSRF protection, and more.

Route::group(['middleware' => ['web']], function () {
    // your routes here
});

这篇关于Laravel - 未按要求设置会话存储的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
PHP最新文章
热门教程
热门工具
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆