首页 文章

页面由于不活动而过期 . 请刷新并再试一次 . laravel 5.6使用laravel的auth

提问于
浏览
1

laravel版本:5.6(最新)php版本:7.1.14系统:Linux Server API:Apache 2.0 Handler

我的问题是,当我在localhost中运行应用程序时,它运行正常,但是当我在服务器上安装此主页时工作正常,但当我尝试登录或尝试注册时显示错误:

"The page has expired due to inactivity. Please refresh and try again"

当我刚删除/ public_html / vendor / laravel / framework / src / Illuminate / Foundation / Exceptions /中的views文件夹时,我得到了这个:

Symfony \ Component \ HttpKernel \ Exception \ HttpException ... / vendor / laravel / framework / src / Illuminate / Foundation / Exceptions / Handler.php204 44 Illuminate \ Foundation \ Exceptions \ Handler prepareException ... / vendor / laravel / framework / src / Illuminate / Foundation / Exceptions / Handler.php176 43 Illuminate \ Foundation \ Exceptions \ Handler render ... / app / Exceptions / Handler.php51 42 App \ Exceptions \ Handler render ... / vendor / laravel / framework / src / Illuminate / Routing / Pipeline.php83 41 Illuminate \ Routing \ Pipeline handleException ... / vendor / laravel / framework / src / Illuminate / Routing / Pipeline.php55 40 Illuminate \ Session \ TokenMismatchException ... / vendor / laravel / framework / src / Illuminate / Foundation / Http / Middleware / VerifyCsrfToken.php70 39 Illuminate \ Foundation \ Http \ Middleware \ VerifyCsrfToken句柄... / vendor / laravel / framework / src / Illuminate / Pipeline / Pipeline.php149 38 Illuminate \ Pipeline \ Pipeline Illuminate \ Pipeline ... / vendor / laravel / framework / src / Illuminate / Routing / Pipeline.php53 37照亮\路由\点eline Illuminate \ Routing ... / vendor / laravel / framework / src / Illuminate / View / Middleware / ShareErrorsFromSession.php49 36 Illuminate \ View \ Middleware \ ShareErrorsFromSession handle ... / vendor / laravel / framework / src / Illuminate / Pipeline / Pipeline .php149 35 Illuminate \ Pipeline \ Pipeline Illuminate \ Pipeline ... / vendor / laravel / framework / src / Illuminate / Routing / Pipeline.php53 34 Illuminate \ Routing \ Pipeline Illuminate \ Routing ... / vendor / laravel / framework /src/Illuminate/Session/Middleware/StartSession.php63 33 Illuminate \ Session \ Middleware \ StartSession handle ... / vendor / laravel / framework / src / Illuminate / Pipeline / Pipeline.php149 32 Illuminate \ Pipeline \ Pipeline Illuminate \ Pipeline ... / vendor / laravel / framework / src / Illuminate / Routing / Pipeline.php53 31 Illuminate \ Routing \ Pipeline Illuminate \ Routing ... / vendor / laravel / framework / src / Illuminate / Cookie / Middleware / AddQueuedCookiesToResponse.php37 30照亮\ Cookie \ Middleware \ AddQueuedCookiesToResponse handle ... / vendo r / laravel / framework / src / Illuminate / Pipeline / Pipeline.php149 29 Illuminate \ Pipeline \ Pipeline Illuminate \ Pipeline ... / vendor / laravel / framework / src / Illuminate / Routing / Pipeline.php53 28 Illuminate \ Routing \ Pipeline Illuminate \ Routing ... / vendor / laravel / framework / src / Illuminate / Cookie / Middleware / EncryptCookies.php59 27 Illuminate \ Cookie \ Middleware \ EncryptCookies handle ... / vendor / laravel / framework / src / Illuminate / Pipeline / Pipeline . php149 26 Illuminate \ Pipeline \ Pipeline Illuminate \ Pipeline ... / vendor / laravel / framework / src / Illuminate / Routing / Pipeline.php53 25 Illuminate \ Routing \ Pipeline Illuminate \ Routing ... / vendor / laravel / framework / src / Illuminate / Pipeline / Pipeline.php102 24 Illuminate \ Pipeline \ Pipeline then ... / vendor / laravel / framework / src / Illuminate / Routing / Router.php661 23 Illuminate \ Routing \ Router runRouteWithinStack ... / vendor / laravel / framework / src / Illuminate / Routing / Router.php636 22 Illuminate \ Routing \ Router runRoute ... / vendor / laravel / framework / src / Il luminate / Routing / Router.php602 21 Illuminate \ Routing \ Router dispatchToRoute ... / vendor / laravel / framework / src / Illuminate / Routing / Router.php591 20 Illuminate \ Routing \ Router dispatch ... / vendor / laravel / framework / src / Illuminate / Foundation / Http / Kernel.php176 19 Illuminate \ Foundation \ Http \ Kernel Illuminate \ Foundation \ Http ... / vendor / laravel / framework / src / Illuminate / Routing / Pipeline.php30 18 Illuminate \ Routing \ Pipeline Illuminate \ Routing ... / vendor / fideloper / proxy / src / TrustProxies.php57 17 Fideloper \ Proxy \ TrustProxies handle ... / vendor / laravel / framework / src / Illuminate / Pipeline / Pipeline.php149 16 Illuminate \ Pipeline \ Pipeline Illuminate \ Pipeline ... / vendor / laravel / framework / src / Illuminate / Routing / Pipeline.php53 15 Illuminate \ Routing \ Pipeline Illuminate \ Routing ... / vendor / laravel / framework / src / Illuminate / Foundation / Http / Middleware / TransformsRequest . php30 14 Illuminate \ Foundation \ Http \ Middleware \ TransformsRequest句柄... / vendor / laravel / framework / src / Illuminate / Pipeline / Pipeline.php149 13 Illuminate \ Pipeline \ Pipeline Illuminate \ Pipeline ... / vendor / laravel / framework / src / Illuminate / Routing / Pipeline.php53 12 Illuminate \ Routing \ Pipeline Illuminate \ Routing ... / vendor / laravel / framework / src / Illuminate / Foundation / Http / Middleware / TransformsRequest.php30 11 Illuminate \ Foundation \ Http \ Middleware \ TransformsRequest handle ... / vendor / laravel / framework / src / Illuminate / Pipeline / Pipeline.php149 10 Illuminate \ Pipeline \ Pipeline Illuminate \ Pipeline ... / vendor / laravel / framework / src / Illuminate / Routing / Pipeline.php53 9 Illuminate \ Routing \ Pipeline Illuminate \ Routing ... / vendor / laravel / framework / src / Illuminate / Foundation / Http / Middleware / ValidatePostSize.php27 8 Illuminate \ Foundation \ Http \ Middleware \ ValidatePostSize handle ... / vendor / laravel / framework / src / Illuminate / Pipeline / Pipeline.php149 7照亮\ Pipeline \ Pipeline Illuminate \ Pipeline ... / vendor / laravel / framework / src / Illumina te / Routing / Pipeline.php53 6 Illuminate \ Routing \ Pipeline Illuminate \ Routing ... / vendor / laravel / framework / src / Illuminate / Foundation / Http / Middleware / CheckForMaintenanceMode.php46 5 Illuminate \ Foundation \ Http \ Middleware \ CheckForMaintenanceMode handle ... / vendor / laravel / framework / src / Illuminate / Pipeline / Pipeline.php149 4 Illuminate \ Pipeline \ Pipeline Illuminate \ Pipeline ... / vendor / laravel / framework / src / Illuminate / Routing / Pipeline.php53 3照亮\ Routing \ Pipeline Illuminate \ Routing ... / vendor / laravel / framework / src / Illuminate / Pipeline / Pipeline.php102 2 Illuminate \ Pipeline \ Pipeline then ... / vendor / laravel / framework / src / Illuminate / Foundation / Http / Kernel .php151 1 Illuminate \ Foundation \ Http \ Kernel sendRequestThroughRouter ... / vendor / laravel / framework / src / Illuminate / Foundation / Http / Kernel.php116

My blade Code:

<div class="form-group row">
    <label for="email" class="col-sm-4 col-form-label text-md-right">{{ __('E-Mail Address') }}</label>
    <div class="col-md-6">
        <input id="email" type="email" class="form-control{{ $errors->has('email') ? ' is-invalid' : '' }}" name="email" value="{{ old('email') }}" required autofocus>
        @if ($errors->has('email'))
            <span class="invalid-feedback">
                 <strong>{{ $errors->first('email') }}</strong>
            </span>
        @endif
    </div>
</div>

<div class="form-group row">
     <label for="password" class="col-md-4 col-form-label text-md-right">{{ __('Password') }}</label>
     <div class="col-md-6">
        <input id="password" type="password" class="form-control{{ $errors->has('password') ? ' is-invalid' : '' }}" name="password" required>
        @if ($errors->has('password'))
            <span class="invalid-feedback">
                 <strong>{{ $errors->first('password') }}</strong>
            </span>
        @endif
     </div>
</div>

<div class="form-group row">
    <div class="col-md-6 offset-md-4">
        <div class="checkbox">
            <label>
                <input type="checkbox" name="remember" {{ old('remember') ? 'checked' : '' }}> {{ __('Remember Me') }}
            </label>
        </div>
    </div>
</div>

<div class="form-group row mb-0">
    <div class="col-md-8 offset-md-4">
        <button type="submit" class="btn btn-primary">
            {{ __('Login') }}
        </button>
        <a class="btn btn-link" href="{{ route('password.request') }}">
            {{ __('Forgot Your Password?') }}
        </a>
    </div>
</div>
</form>

如何解决这个问题?我也尝试了以前的所有问题建议 . 我也看到它是 'domain' => env('SESSION_DOMAIN', null) ,并且在.env中没有像session_domain那样

2 回答

  • 1

    您需要将csrf_filed添加到表单中 . 在打开表单标记之后添加它 .

    {{ csrf_field() }}
    

    编辑:在laravel 5.6中,您可以在表单标记之后执行 @csrf .

  • 0

    此问题来自CSRF令牌验证失败 .

    它适用于GET的原因是对于laravel中的GET路由,没有发布CSRF令牌 .

    只需将此代码放在表单中即可

    {{ csrf_field() }}
    

    Update For Laravel 5.6

    Laravel 5.6使用Blades模板,非常简单 .

    <form action="">
       @csrf
       ...
    </form>
    

相关问题